ardupilot/Tools/completion/bash/_sim_vehicle

98 lines
2.4 KiB
Plaintext
Raw Normal View History

2019-10-28 08:41:00 -03:00
#!/usr/bin/env bash
_sim_vehicle() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
# don't complet =
_init_completion -n = || return
2019-10-28 08:41:00 -03:00
# TODO: generate for waf help
opts="--help -h"
opts+=" -j --jobs"
opts+=" -N --no-rebuild"
opts+=" -D --debug"
opts+=" -c --clean"
opts+=" -I --instance"
opts+=" -V --valgrind"
opts+=" --callgrind"
opts+=" -T --tracker"
opts+=" -A --sitl-instance-args"
opts+=" -G --gdb"
opts+=" -g --gdb-stopped"
opts+=" --lldb"
opts+=" --lldb-stopped"
opts+=" -d --delay-start"
opts+=" -B --breakpoint"
opts+=" -M --mavlink-gimbal"
opts+=" -L --location"
opts+=" -l --custom-location"
opts+=" -S --speedup"
opts+=" -t --tracker-location"
opts+=" -w --wipe-eeprom"
opts+=" -m --mavproxy-args"
opts+=" --strace"
opts+=" --model"
opts+=" --use-dir"
opts+=" --no-mavproxy"
opts+=" --fresh-params"
opts+=" --mcast"
opts+=" --osd"
opts+=" --tonealarm"
opts+=" --rgbled"
opts+=" --add-param-file"
opts+=" --no-extra-ports"
opts+=" -Z --swarm"
opts+=" --flash-storage"
opts+=" --out"
opts+=" --map"
opts+=" --console"
opts+=" --aircraft"
opts+=" --moddebug"
opts+=" -v --vehicle"
opts+=" -f --frame"
# Prevent word reuse TODO: add -vvv case
lim=$((COMP_CWORD - 1))
for i in $(seq 0 $lim); do
if [[ $opts == *"${COMP_WORDS[i]}"* ]]; then
opts=${opts//${COMP_WORDS[i]}/}
opts=${opts//--${COMP_WORDS[i]}/}
2019-10-28 08:41:00 -03:00
fi
done
case $prev in
-v | --vehicle)
# get the calling program, remove anything after the space == all commands arguments
local caller; caller=$(echo $@ | sed 's/ .*//g');
opts=$($caller --list-vehicle)
2019-10-28 08:41:00 -03:00
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
;;
-f | --frame)
# get the calling program, remove anything after the space == all commands arguments
local caller; caller=$(echo $@ | sed 's/ .*//g');
local supported_vehicle_list=$($caller --list-vehicle)
local frames;
for v in $supported_vehicle_list
do
if [[ ${COMP_WORDS[@]} == *"$v"* ]]
then
frames=$($caller --list-frame "$v")
break
fi
done
COMPREPLY=($(compgen -W "${frames}" -- ${cur}))
return 0
2019-10-28 08:41:00 -03:00
;;
esac
COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") $(compgen -W "${opts}" -- ${cur}) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
2019-10-28 08:41:00 -03:00
}
complete -F _sim_vehicle sim_vehicle.py