mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-06 19:00:27 +08:00
73 lines
2.0 KiB
Bash
Executable File
73 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
_ap_bin()
|
|
{
|
|
local cur prev opts
|
|
COMPREPLY=()
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
|
|
case $prev in
|
|
-M | --model)
|
|
# extract the frame names from the embedded vehicleinfo.json
|
|
opts=$("$1" --list-models 2>/dev/null | python3 -c 'import json,sys; d=json.load(sys.stdin); print(" ".join(sorted({f for v in d.values() for f in v.get("frames", {})})))' 2>/dev/null)
|
|
mapfile -t COMPREPLY < <(compgen -W "${opts}" -- "${cur}")
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
opts="--help -h"
|
|
opts+=" --wipe -w"
|
|
opts+=" --unhide-groups -u"
|
|
opts+=" --speedup -s"
|
|
opts+=" --rate -r"
|
|
opts+=" --console -C"
|
|
opts+=" --instance -I"
|
|
opts+=" --home -O"
|
|
opts+=" --model -M"
|
|
opts+=" --fg -F"
|
|
opts+=" --config"
|
|
opts+=" --enable-fgview"
|
|
opts+=" --gimbal"
|
|
opts+=" --autotest-dir"
|
|
opts+=" --defaults"
|
|
opts+=" --serial0"
|
|
opts+=" --serial1"
|
|
opts+=" --serial2"
|
|
opts+=" --serial3"
|
|
opts+=" --serial4"
|
|
opts+=" --serial5"
|
|
opts+=" --serial6"
|
|
opts+=" --serial7"
|
|
opts+=" --serial8"
|
|
opts+=" --serial9"
|
|
opts+=" --start-time"
|
|
opts+=" --sysid"
|
|
opts+=" --slave"
|
|
opts+=" --base-port"
|
|
opts+=" --rc-in-port"
|
|
opts+=" --sim-address"
|
|
opts+=" --sim-port-in"
|
|
opts+=" --sim-port-out"
|
|
opts+=" --irlock-port"
|
|
# Prevent word reuse
|
|
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]}/}
|
|
fi
|
|
done
|
|
# shellcheck disable=SC2016 # compgen -W expands the command substitution itself
|
|
mapfile -t COMPREPLY < <(compgen -W '$(_parse_help "$1")' -- "$cur")
|
|
mapfile -t -O "${#COMPREPLY[@]}" COMPREPLY < <(compgen -W "${opts}" -- "${cur}")
|
|
}
|
|
|
|
|
|
complete -F _ap_bin arducopter
|
|
complete -F _ap_bin arducopter-heli
|
|
complete -F _ap_bin arduplane
|
|
complete -F _ap_bin ardurover
|
|
complete -F _ap_bin ardusub
|
|
complete -F _ap_bin antennatracker
|