From b247f2830b5e49fb5603289c09f516634430678a Mon Sep 17 00:00:00 2001 From: Pierre Kancir Date: Sun, 19 Jan 2020 21:01:58 +0100 Subject: [PATCH] Tools: add completion for vehicle binaries --- Tools/completion/bash/_ap_bin | 47 ++++++++++++++++++++++++++++++++ Tools/completion/completion.bash | 2 +- Tools/completion/zsh/_ap_bin | 42 ++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 Tools/completion/bash/_ap_bin create mode 100644 Tools/completion/zsh/_ap_bin diff --git a/Tools/completion/bash/_ap_bin b/Tools/completion/bash/_ap_bin new file mode 100644 index 0000000000..a119d04169 --- /dev/null +++ b/Tools/completion/bash/_ap_bin @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +_ap_bin() +{ + local cur opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + + opts="--help -h" + opts+=" --wipe -w" + opts+=" --unhide-groups -u" + opts+=" --speedup -s SPEEDUP" + opts+=" --rate -r" + opts+=" --console -C" + opts+=" --instance -I" + opts+=" --synthetic-clock -S" + opts+=" --home -O" + opts+=" --model -M" + opts+=" --config" + opts+=" --fg -F" + opts+=" --disable-fgview" + opts+=" --gimbal" + opts+=" --autotest-dir" + opts+=" --defaults" + opts+=" --uartA" + opts+=" --uartB" + opts+=" --uartC" + opts+=" --uartD" + opts+=" --uartE" + opts+=" --uartF" + opts+=" --uartG" + opts+=" --uartH" + opts+=" --rtscts" + opts+=" --base-port" + opts+=" --rc-in-port" + opts+=" --sim-address" + opts+=" --sim-port-in" + opts+=" --sim-port-out" + opts+=" --irlock-port" + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) +} + + +complete -F _ap_bin arducopter +complete -F _ap_bin arduplane +complete -F _ap_bin ardusub +complete -F _ap_bin arducopter diff --git a/Tools/completion/completion.bash b/Tools/completion/completion.bash index 4970f81aa7..0cf82a7df9 100644 --- a/Tools/completion/completion.bash +++ b/Tools/completion/completion.bash @@ -3,4 +3,4 @@ _AP_COMPLETION_DIR=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null && pwd) source "$_AP_COMPLETION_DIR/bash/_waf" source "$_AP_COMPLETION_DIR/bash/_sim_vehicle" - +source "$_AP_COMPLETION_DIR/bash/_ap_bin" diff --git a/Tools/completion/zsh/_ap_bin b/Tools/completion/zsh/_ap_bin new file mode 100644 index 0000000000..7807d0a693 --- /dev/null +++ b/Tools/completion/zsh/_ap_bin @@ -0,0 +1,42 @@ +#compdef arducopter arducopter-heli arduplane ardurover ardusub antennatracker +#autoload + +_ap_bin() { + typeset -A opt_args + local context state line curcontext="$curcontext" + + _arguments -C -A -s -S \ + '(- 1 *)'{-h,--help}'[display this help information]' \ + '(-w --wipe)'{-w,--wipe}'[wipe eeprom]' \ + '(-u --unhide-groups)'{-u,--unhide-groups}'[parameter enumeration ignores AP_PARAM_FLAG_ENABLE]' \ + '(-s --speedup)'{-s,--speedup}'[set simulation speedup]:float' \ + '(-r --rate)'{-r,--rate}'[set SITL framerate]:float' \ + '(-C --console)'{-C,--console}'[use console instead of TCP ports]' \ + '(-I --instance)'{-I,--instance}'[set instance of SITL (adds 10*instance to all port numbers)]:int:' \ + '(-O --home)'{-O,--home}'[set start location (lat,lng,alt,yaw)]:int:' \ + '(-M --model)'{-M,--model}'[set simulation model]' \ + '--config[set additional simulation config string]:CONFIG' \ + '(-F --fg)'{-F,--fg}'[set Flight Gear view address, defaults to 127.0.0.1]:ADDRESS' \ + '--disable-fgview[disable Flight Gear view]' \ + '--gimbal[enable simulated MAVLink gimbal]' \ + '--autotest-dir[set directory for additional files]:DIR:' \ + '--defaults[set path to defaults file]:PATH:' \ + '--uartA[set device string for UARTA]:DEVICE:' \ + '--uartB[set device string for UARTB]:DEVICE:' \ + '--uartC[set device string for UARTC]:DEVICE:' \ + '--uartD[set device string for UARTD]:DEVICE:' \ + '--uartE[set device string for UARTE]:DEVICE:' \ + '--uartF[set device string for UARTF]:DEVICE:' \ + '--uartG[set device string for UARTG]:DEVICE:' \ + '--uartH[set device string for UARTH]:DEVICE:' \ + '--rtscts[enable rtscts on serial ports (default false)]' \ + '--base-port[set port num for base port(default 5670) must be before -I option]:PORT:' \ + '--rc-in-port[set port num for rc in]:PORT:' \ + '--sim-address[set address string for simulator]:STRING:' \ + '--sim-port-in[set port num for simulator in]:PORT:' \ + '--sim-port-out[set port num for simulator out]:PORT:' \ + '--irlock-port[set port num for irlock]:PORT:' \ + && ret=0 +} + +_ap_bin "$@"