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]}"
|
2021-01-02 16:38:44 -04:00
|
|
|
# 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
|
2020-04-03 12:38:17 -03:00
|
|
|
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)
|
2019-11-14 12:21:44 -04:00
|
|
|
# get the calling program, remove anything after the space == all commands arguments
|
|
|
|
local caller; caller=$(echo $@ | sed 's/ .*//g');
|
2020-07-09 16:28:47 -03:00
|
|
|
opts=$($caller --list-vehicle)
|
2019-10-28 08:41:00 -03:00
|
|
|
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
-f | --frame)
|
2019-11-14 12:21:44 -04:00
|
|
|
# get the calling program, remove anything after the space == all commands arguments
|
|
|
|
local caller; caller=$(echo $@ | sed 's/ .*//g');
|
2020-08-03 09:37:28 -03:00
|
|
|
local supported_vehicle_list=$($caller --list-vehicle)
|
2019-11-14 12:21:44 -04:00
|
|
|
local frames;
|
|
|
|
for v in $supported_vehicle_list
|
|
|
|
do
|
|
|
|
if [[ ${COMP_WORDS[@]} == *"$v"* ]]
|
|
|
|
then
|
2020-07-09 16:28:47 -03:00
|
|
|
frames=$($caller --list-frame "$v")
|
2019-11-14 12:21:44 -04:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
COMPREPLY=($(compgen -W "${frames}" -- ${cur}))
|
|
|
|
return 0
|
|
|
|
|
2019-10-28 08:41:00 -03:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2021-01-02 16:38:44 -04:00
|
|
|
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
|
|
|
|
|