Tools: completion: small correction to zsh

This commit is contained in:
Pierre Kancir 2020-04-06 16:36:51 +02:00 committed by Andrew Tridgell
parent 5736e28693
commit 6dce7a88d4
3 changed files with 7 additions and 13 deletions

View File

@ -5,7 +5,7 @@ _ap_bin() {
typeset -A opt_args
local context state line curcontext="$curcontext"
_arguments -C -A -s -S \
_arguments -C \
'(- 1 *)'{-h,--help}'[display this help information]' \
'(-w --wipe)'{-w,--wipe}'[wipe eeprom]' \
'(-u --unhide-groups)'{-u,--unhide-groups}'[parameter enumeration ignores AP_PARAM_FLAG_ENABLE]' \

View File

@ -1,16 +1,13 @@
#compdef sim_vehicle.py
#autoload
local temp_word
local cur cword prev
local -a vehicles
_sim_vehicle() {
typeset -A opt_args
local context state state_descr line curcontext="$curcontext"
cur=${words[CURRENT]}
prev=${words[CURRENT-1]}
_arguments -C -A -s -S \
_arguments -C \
'(- 1 *)'{-h,--help}'[show help options and exit]' \
'(-j --jobs)'{-j,--jobs}'[number of processors to use during build]:int:' \
'(-N --no-rebuild)'{-N,--no-rebuild}'[do not rebuild before starting ardupilot]' \
@ -61,8 +58,6 @@ _sim_vehicle() {
}
_get_vehicle_type() {
# get the calling program, remove anything after the space == all commands arguments
local caller; caller=$(echo ${words[@]} | sed 's/ .*//g');
# get options between "vehicle type " and closing ")", remove line return, remove spaces, anything before the opening (, remove the "|" and closing ")"
vehicles=( $($caller --help | sed -n '/vehicle type (/,/)/p' | tr '\n' ' ' | sed -e 's/ //g' -e 's/.*(//g' -e 's/[|)]/ /g') )
}
@ -95,9 +90,6 @@ do
local_current=$(( $local_current - 1 ))
done
# get the calling program, remove anything after the space == all commands arguments
local caller; caller=$(echo ${words[@]} | sed 's/ .*//g');
# to get the vehicle list :
# Get everything between "frame type" and "-C", remove first and last line, get line starting with caracters and ": " sequence, remove spaces and :
local supported_vehicle_list=($($caller --help | sed -n '/frame type/,/-C/p' | sed -e '1d' -e '$d' | sed -n 's/\(.*: \).*/\1/p' | sed -e 's/ //g' -e 's/://g'))
@ -118,4 +110,6 @@ done
_describe -t frames 'frame' frames "$@" && ret=0
}
# get the calling program, remove anything after the space == all commands arguments
caller=$(echo ${words[@]} | sed 's/ .*//g');
_sim_vehicle "$@"

View File

@ -5,7 +5,7 @@ _waf() {
typeset -A opt_args
local context state line curcontext="$curcontext"
_arguments -C -A -s -S \
_arguments -C \
'(- 1 *)--version[show version and exit]' \
'(- 1 *)'{-h,--help}'[show help options and exit]' \
'1:first arg:_waf_cmds' \