OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # Add programmable completion to some Chromium OS build scripts | 5 # Add programmable completion to some Chromium OS build scripts |
6 | 6 |
7 | 7 |
8 # Echo a list of -- flags that the current command accepts. The | 8 # Echo a list of -- flags that the current command accepts. The |
9 # function assumes that the command supports shflags' --help flag. | 9 # function assumes that the command supports shflags' --help flag. |
10 _flags() { | 10 _flags() { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 "$repo" help --all | grep -E '^ ' | sed 's/ \([^ ]\+\) .\+/\1/' | 193 "$repo" help --all | grep -E '^ ' | sed 's/ \([^ ]\+\) .\+/\1/' |
194 } | 194 } |
195 | 195 |
196 _list_repo_branches() { | 196 _list_repo_branches() { |
197 local repo=${COMP_WORDS[0]} | 197 local repo=${COMP_WORDS[0]} |
198 "$repo" branches 2>&1 | grep \| | sed 's/[ *][Pp ] *\([^ ]\+\) .*/\1/' | 198 "$repo" branches 2>&1 | grep \| | sed 's/[ *][Pp ] *\([^ ]\+\) .*/\1/' |
199 } | 199 } |
200 | 200 |
201 _list_repo_projects() { | 201 _list_repo_projects() { |
202 local repo=${COMP_WORDS[0]} | 202 local repo=${COMP_WORDS[0]} |
203 local manifest=$(mktemp) | 203 "$repo" manifest -o /dev/stdout 2> /dev/null \ |
204 "$repo" manifest -o "$manifest" >& /dev/null | 204 | grep 'project name=' \ |
205 grep 'project name=' "$manifest" | sed 's/.\+name="\([^"]\+\)".\+/\1/' | 205 | sed 's/.\+name="\([^"]\+\)".\+/\1/' |
206 rm -f "$manifest" >& /dev/null | |
207 } | 206 } |
208 | 207 |
209 # Complete repo's <command> argument. | 208 # Complete repo's <command> argument. |
210 _complete_repo_command() { | 209 _complete_repo_command() { |
211 [ ${COMP_CWORD} -eq 1 ] || return 1 | 210 [ ${COMP_CWORD} -eq 1 ] || return 1 |
212 local command=${COMP_WORDS[1]} | 211 local command=${COMP_WORDS[1]} |
213 COMPREPLY=($(compgen -W "$(_list_repo_commands)" -- "$command")) | 212 COMPREPLY=($(compgen -W "$(_list_repo_commands)" -- "$command")) |
214 return 0 | 213 return 0 |
215 } | 214 } |
216 | 215 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 image_to_usb.sh \ | 253 image_to_usb.sh \ |
255 mod_image_for_test.sh | 254 mod_image_for_test.sh |
256 complete -o bashdefault -o default -F _board_overlay setup_board | 255 complete -o bashdefault -o default -F _board_overlay setup_board |
257 complete -o bashdefault -o default -o nospace -F _autotest_complete autotest | 256 complete -o bashdefault -o default -o nospace -F _autotest_complete autotest |
258 complete -F _cros_workon cros_workon | 257 complete -F _cros_workon cros_workon |
259 complete -F _complete_repo repo | 258 complete -F _complete_repo repo |
260 | 259 |
261 ### Local Variables: | 260 ### Local Variables: |
262 ### mode: shell-script | 261 ### mode: shell-script |
263 ### End: | 262 ### End: |
OLD | NEW |