mirror of https://github.com/ArduPilot/ardupilot
Tools: completion: bash complete subtest on autotest.py
This commit is contained in:
parent
5f033a551a
commit
60f2e119a5
|
@ -5,42 +5,16 @@ _ap_autotest() {
|
|||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD - 1]}"
|
||||
# don't complet =
|
||||
_init_completion -n = || return
|
||||
|
||||
# get the calling program, remove anything after the space == all commands arguments
|
||||
local caller
|
||||
caller=$(echo $@ | sed 's/ .*//g')
|
||||
opts=$($caller --list | sed -n -e '/^build/p' -e '/^test/p' -e '/^run/p')
|
||||
tests=$($caller --list-vehicles-test | sed -n '/Copter/p')
|
||||
opts+=$(compgen -W "${tests}" -P "test.")
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
# TODO: generate for waf help
|
||||
opts="--help -h"
|
||||
opts+=" -j"
|
||||
opts+=" --skip"
|
||||
opts+=" --list"
|
||||
opts+=" --list-subtests"
|
||||
opts+=" --viewerip"
|
||||
opts+=" --map"
|
||||
opts+=" --experimental"
|
||||
opts+=" --timeout"
|
||||
opts+=" --frame"
|
||||
opts+=" --show-test-timings"
|
||||
opts+=" --validate-parameters"
|
||||
opts+=" --no-configure"
|
||||
opts+=" --waf-configure-args"
|
||||
opts+=" --no-clean"
|
||||
opts+=" --debug"
|
||||
opts+=" --speedup"
|
||||
opts+=" --valgrind"
|
||||
opts+=" --gdb"
|
||||
opts+=" --gdbserver"
|
||||
opts+=" --lldb"
|
||||
opts+=" -B --breakpoint"
|
||||
opts+=" --disable-breakpoints"
|
||||
;;
|
||||
*)
|
||||
# get the calling program, remove anything after the space == all commands arguments
|
||||
local caller
|
||||
caller=$(echo $@ | sed 's/ .*//g')
|
||||
opts=$($caller --list)
|
||||
;;
|
||||
# TODO: add completion for subtests and skip list
|
||||
esac
|
||||
# Prevent word reuse
|
||||
lim=$((COMP_CWORD - 1))
|
||||
for i in $(seq 0 $lim); do
|
||||
|
@ -49,7 +23,35 @@ _ap_autotest() {
|
|||
opts=${opts//--${COMP_WORDS[i]}/}
|
||||
fi
|
||||
done
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
|
||||
case $cur in
|
||||
test.*.*)
|
||||
local supported_vehicle_list
|
||||
supported_vehicle_list=$($caller --list-vehicles | sed -n '/Copter/p')
|
||||
local vehicle
|
||||
# get the part before the last dot
|
||||
lcur=${cur%.*}
|
||||
# search for the right vehicle name in the list
|
||||
# TODO : just extract the caracters between the two dot with bash and use python to extract the right subtests
|
||||
for v in $supported_vehicle_list
|
||||
do
|
||||
if [[ ${lcur} == *"$v"* ]]
|
||||
then
|
||||
vehicle=$v
|
||||
break
|
||||
fi
|
||||
done
|
||||
azr=$($caller --list-subtests-for-vehicle "${vehicle}")
|
||||
# append back the last dot
|
||||
lcur="${lcur}."
|
||||
opts=$(compgen -W "${azr}" -P "${lcur}")
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
;;
|
||||
esac
|
||||
|
||||
COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") $(compgen -W "${opts}" -- ${cur}) )
|
||||
[[ ${COMPREPLY-} == *. ]] && compopt -o nospace
|
||||
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
|
||||
}
|
||||
|
||||
complete -F _ap_autotest autotest.py
|
||||
|
|
Loading…
Reference in New Issue