diff --git a/Tools/completion/bash/_ap_autotest b/Tools/completion/bash/_ap_autotest new file mode 100644 index 0000000000..79968bf90f --- /dev/null +++ b/Tools/completion/bash/_ap_autotest @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +_ap_autotest() { + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD - 1]}" + + 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 + if [[ $opts == *"${COMP_WORDS[i]}"* ]]; then + opts=${opts//${COMP_WORDS[i]}/} + opts=${opts//--${COMP_WORDS[i]}/} + fi + done + COMPREPLY=($(compgen -W "${opts}" -- ${cur})) +} + +complete -F _ap_autotest autotest.py diff --git a/Tools/completion/completion.bash b/Tools/completion/completion.bash index 0cf82a7df9..ae5c04cd3c 100644 --- a/Tools/completion/completion.bash +++ b/Tools/completion/completion.bash @@ -4,3 +4,4 @@ _AP_COMPLETION_DIR=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null && p source "$_AP_COMPLETION_DIR/bash/_waf" source "$_AP_COMPLETION_DIR/bash/_sim_vehicle" source "$_AP_COMPLETION_DIR/bash/_ap_bin" +source "$_AP_COMPLETION_DIR/bash/_ap_autotest"