diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /python/mach/mach/commands/completion_templates/zsh.template | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'python/mach/mach/commands/completion_templates/zsh.template')
-rw-r--r-- | python/mach/mach/commands/completion_templates/zsh.template | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/python/mach/mach/commands/completion_templates/zsh.template b/python/mach/mach/commands/completion_templates/zsh.template new file mode 100644 index 0000000000..21677841ef --- /dev/null +++ b/python/mach/mach/commands/completion_templates/zsh.template @@ -0,0 +1,62 @@ +#compdef mach +_mach_complete() +{ + local com coms comsubs cur optkey opts state sub subs + cur=${words[${#words[@]}]} + typeset -A comsubs + comsubs=( %(commands_subcommands)s ) + + # lookup for command and subcommand + for word in ${words[@]:1}; do + if [[ $word == -* ]]; then + continue + fi + + if [[ -z $com ]]; then + com=$word + elif [[ ${comsubs[$com]} == *" $word "* ]]; then + sub=$word + break + fi + done + + # check for a subcommand + if [[ $cur == $com ]]; then + state="command" + coms=(%(commands)s) + elif [[ ${cur} == -* ]]; then + state="option" + if [[ -z $com ]]; then + # no command, use global options + opts=(%(globalopts)s) + fi + fi + case $state in + (command) + _describe 'command' coms + ;; + (option) + if [[ -n $sub ]]; then + optkey="$com $sub" + else + optkey="$com" + fi + case $optkey in +%(case_options)s + esac + _describe 'option' opts + ;; + *) + if [[ -z $sub ]]; then + # if we're completing a command with subcommands, add them here + case "$com" in +%(case_subcommands)s + esac + _describe 'subcommand' subs + fi + # also fallback to file completion + _arguments '*:file:_files' + esac +} +_mach_complete "$@" +compdef _mach_complete mach |