browse.py: allow port override via environment variable
[platform/upstream/ninja.git] / misc / zsh-completion
1 #compdef ninja
2 # Copyright 2011 Google Inc. All Rights Reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 # Add the following to your .zshrc to tab-complete ninja targets
17 #   . path/to/ninja/misc/zsh-completion
18
19 __get_targets() {
20   dir="."
21   if [ -n "${opt_args[-C]}" ];
22   then
23     eval dir="${opt_args[-C]}"
24   fi
25   targets_command="ninja -C \"${dir}\" -t targets all"
26   eval ${targets_command} 2>/dev/null | cut -d: -f1
27 }
28
29 __get_tools() {
30   ninja -t list 2>/dev/null | while read -r a b; do echo $a; done | tail -n +2
31 }
32
33 __get_modes() {
34   ninja -d list 2>/dev/null | while read -r a b; do echo $a; done | tail -n +2 | sed '$d'
35 }
36
37 __modes() {
38   local -a modes
39   modes=(${(fo)"$(__get_modes)"})
40   _describe 'modes' modes
41 }
42
43 __tools() {
44   local -a tools
45   tools=(${(fo)"$(__get_tools)"})
46   _describe 'tools' tools
47 }
48
49 __targets() {
50   local -a targets
51   targets=(${(fo)"$(__get_targets)"})
52   _describe 'targets' targets
53 }
54
55 _arguments \
56   {-h,--help}'[Show help]' \
57   '--version[Print ninja version]' \
58   '-C+[Change to directory before doing anything else]:directories:_directories' \
59   '-f+[Specify input build file (default=build.ninja)]:files:_files' \
60   '-j+[Run N jobs in parallel (default=number of CPUs available)]:number of jobs' \
61   '-l+[Do not start new jobs if the load average is greater than N]:number of jobs' \
62   '-k+[Keep going until N jobs fail (default=1)]:number of jobs' \
63   '-n[Dry run (do not run commands but act like they succeeded)]' \
64   '-v[Show all command lines while building]' \
65   '-d+[Enable debugging (use -d list to list modes)]:modes:__modes' \
66   '-t+[Run a subtool (use -t list to list subtools)]:tools:__tools' \
67   '*::targets:__targets'