Browse Source

Tools: completion: autotest subtest completion for ZSH

zr-v5.1
Pierre Kancir 5 years ago committed by Peter Barker
parent
commit
25c42b0ea9
  1. 59
      Tools/completion/zsh/_ap_autotest

59
Tools/completion/zsh/_ap_autotest

@ -6,17 +6,16 @@ _ap_autotest() { @@ -6,17 +6,16 @@ _ap_autotest() {
local context state line curcontext="$curcontext"
_arguments -C \
'(- 1 *)'{-h,--help}'[show help options and exit]' \
': :_ap_autotest_cmds' \
'*:: :->args' &&
ret=0
'(- 1 *)--list[list the available steps]' \
'(- 1 *)--list-subtests[list available subtests e.g. test.Copter]' \
':first parameter:_ap_autotest_cmds' \
'*:: :->args'
case "$state" in
(args)
_arguments -C \
'--skip[list of steps to skip (comma separated)]' \
'(-j --jobs)'{-j,--jobs}'[number of processors to use during build]:int:' \
'--skip[list of steps to skip (comma separated)]' \
'--list[list the available steps]' \
'--list-subtests[list available subtests e.g. test.Copter]' \
'--viewerip[IP address to send MAVLink and fg packets to]:VIEWERIP:' \
'--map[show map]' \
'--experimental[enable experimental tests]' \
@ -30,20 +29,60 @@ _ap_autotest() { @@ -30,20 +29,60 @@ _ap_autotest() {
'--debug[make built binaries debug binaries]' \
'--speedup[speedup to run the simulations at]:SPEEDUP:' \
'--valgrind[run ArduPilot binaries under valgrind]' \
'--gdb[run ArduPilot binaries under gdb]' \
'--gdb[run ArduPilot ot binaries under gdb]' \
'--gdbserver[run ArduPilot binaries under gdbserver]' \
'(-B --breakpoint)'{-B,--breakpoint}'[add a breakpoint at given location in debugger]:BREAKPOINT:' \
'--disable-breakpoints[disable all breakpoints before starting]' \
'*: :_ap_autotest_cmds' \
&& ret=0
;;
esac
}
(( $+functions[_ap_autotest_cmds] )) ||
_ap_autotest_cmds() {
default_options=( $($caller --list))
_describe -t default-options 'default_options' default_options "$@" && ret=0
local suf
local tasks
# check we are on something like test.Copter
if compset -P '*[.]*[.]'; then
local type; type="$(echo ${words[$CURRENT]} | cut -d'.' -f1)"
local vehicle; vehicle="$(echo ${words[$CURRENT]} | cut -d'.' -f2)"
# check that we want completing test
case $type in
test)
tasks=( $($caller --list-subtests-for-vehicle $vehicle) )
suf=( -qS '.' )
_wanted "vehiclfdsfses" expl "vehifdsfcle" compadd $tasks && return 0
;;
esac
else
# check we are on something like test.
if compset -P '*[.]'; then
local type; type="$(echo ${words[$CURRENT]} | cut -d'.' -f1)"
case $type in
test)
tasks=( $($caller --list-vehicles-test) )
# add dot after vehicle name for further completion
suf=( -qS '.' )
;;
build)
# remove first and last line, get the lines starting with build, replace line return by space
tasks=( $($caller --list | sed -e '1d' -e '$d' | sed -n 's/\bbuild\b.*\.//p' | tr '\n' ' ') )
# don't add more dot on non test
suf=( )
;;
run)
# remove first and last line, get the lines starting with run, replace line return by space
tasks=( $($caller --list | sed -e '1d' -e '$d' | sed -n 's/\brun\b.*\.//p' | tr '\n' ' ' ) )
# don't add more dot on non test
suf=( )
;;
esac
else
tasks=(build test run)
suf=( -qS '.' )
fi
_wanted "schemes" expl "scheme" compadd $suf[@] $tasks && return 0
fi
}
# get the calling program, remove anything after the space == all commands arguments

Loading…
Cancel
Save