gecko-dev/python/mach/bash-completion.sh
Andrew Halberstadt 8905ad4bab Bug 1518586 - [mach] Implement bash completion for subcommands and arguments r=nalexander
Since we're calling into a mach command for the current completion
implementation anyway (and incurring python startup penalties), we
might as well move all the bash logic into the mach command.

The new 'mach-completion' command was created in case there are
scripts relying on the current behaviour of 'mach-commands'.

Depends on D16254

Differential Revision: https://phabricator.services.mozilla.com/D16255

--HG--
extra : moz-landing-system : lando
2019-01-11 15:28:49 +00:00

19 lines
478 B
Bash

function _mach()
{
local cur targets
COMPREPLY=()
# Calling `mach-completion` with -h/--help would result in the
# help text being used as the completion targets.
if [[ $COMP_LINE == *"-h"* || $COMP_LINE == *"--help"* ]]; then
return 0
fi
# Load the list of targets
targets=`"${COMP_WORDS[0]}" mach-completion ${COMP_LINE}`
cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( $(compgen -W "$targets" -- ${cur}) )
return 0
}
complete -o default -F _mach mach