diff options
Diffstat (limited to 'completions/mdtool')
-rw-r--r-- | completions/mdtool | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/completions/mdtool b/completions/mdtool index 428e33b..cd179e5 100644 --- a/completions/mdtool +++ b/completions/mdtool @@ -1,32 +1,30 @@ # mdtool completion -*- shell-script -*- -_mdtool() +_comp_cmd_mdtool() { - local cur prev words cword - _init_completion || return + local cur prev words cword comp_args + _comp_initialize -- "$@" || return - local command i - - for ((i = 1; i < ${#words[@]} - 1; i++)); do + local command="" i + for ((i = 1; i < cword; i++)); do if [[ ${words[i]} == @(build|generate-makefiles|setup) ]]; then command=${words[i]} break fi done - if [[ -v command ]]; then + if [[ $command ]]; then case $command in "build") - COMPREPLY=($(compgen -W '--f --buildfile --p --project' \ - -S":" -- "$cur")) + _comp_compgen -- -W '--f --buildfile --p --project' -S":" # TODO: This does not work :( #if [[ "$prev" == *: ]]; then # case $prev in # @(--p:|--project:)) - # COMPREPLY=( $(compgen -f -G "*.mdp" -- "$cur") ) + # _comp_compgen -- -f -G "*.mdp" # ;; # @(--f:|--buildfile:)) - # COMPREPLY=( $(compgen -f -G "*.mdp" -G "*.mds" -- "$cur") ) + # _comp_compgen -- -f -G "*.mdp" -G "*.mds" # ;; # esac #fi @@ -34,29 +32,27 @@ _mdtool() ;; "generate-makefiles") compopt -o filenames - COMPREPLY=($(compgen -o filenames -G"*.mds" -- "$cur")) + _comp_compgen -- -o filenames -G"*.mds" if [[ $prev == *mds ]]; then - COMPREPLY=($(compgen -W '--simple-makefiles --s --d:' \ - -- "$cur")) + _comp_compgen -- -W '--simple-makefiles --s --d:' fi return ;; "setup") # TODO: at least return filenames after these options. - COMPREPLY=($(compgen -W 'install i uninstall u check-install - ci update up list l list-av la list-update lu rep-add ra + _comp_compgen -- -W 'install i uninstall u check-install ci + update up list l list-av la list-update lu rep-add ra rep-remove rr rep-update ru rep-list rl reg-update - reg-build rgu info rep-build rb pack p help h dump-file' \ - -- "$cur")) + reg-build rgu info rep-build rb pack p help h dump-file' return ;; esac fi - COMPREPLY=($(compgen -W 'gsetup build dbgen project-export - generate-makefiles gettext-update setup -q' -- "$cur")) + _comp_compgen -- -W 'gsetup build dbgen project-export generate-makefiles + gettext-update setup -q' } && - complete -F _mdtool mdtool + complete -F _comp_cmd_mdtool mdtool # ex: filetype=sh |