From 6dce7a88d4ee7eb034a00aac99d849ca5c2b9c21 Mon Sep 17 00:00:00 2001 From: Pierre Kancir Date: Mon, 6 Apr 2020 16:36:51 +0200 Subject: [PATCH] Tools: completion: small correction to zsh --- Tools/completion/zsh/_ap_bin | 2 +- Tools/completion/zsh/_sim_vehicle | 16 +++++----------- Tools/completion/zsh/_waf | 2 +- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/Tools/completion/zsh/_ap_bin b/Tools/completion/zsh/_ap_bin index 7807d0a693..3bf5d41b32 100644 --- a/Tools/completion/zsh/_ap_bin +++ b/Tools/completion/zsh/_ap_bin @@ -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]' \ diff --git a/Tools/completion/zsh/_sim_vehicle b/Tools/completion/zsh/_sim_vehicle index 78e2c18c96..fd4f9a2fdb 100644 --- a/Tools/completion/zsh/_sim_vehicle +++ b/Tools/completion/zsh/_sim_vehicle @@ -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]' \ @@ -56,13 +53,11 @@ _sim_vehicle() { '(-v --vehicle)'{-v,--vehicle}'[vehicle type]:vehicle:_sim_vehicle_vehicles' \ '(-f --frame)'{-f,--frame}'[set vehicle frame type]:frame:_copter_frames' \ && ret=0 - + } _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 "$@" diff --git a/Tools/completion/zsh/_waf b/Tools/completion/zsh/_waf index a5331067ef..f0f167845a 100644 --- a/Tools/completion/zsh/_waf +++ b/Tools/completion/zsh/_waf @@ -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' \