diff options
Diffstat (limited to 'completions/dmypy')
-rw-r--r-- | completions/dmypy | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/completions/dmypy b/completions/dmypy index 5abe37d..7fab74f 100644 --- a/completions/dmypy +++ b/completions/dmypy @@ -1,48 +1,49 @@ # dmypy completion -*- shell-script -*- -_dmypy() +_comp_cmd_dmypy() { - local cur prev words cword - _init_completion || return + local cur prev words cword comp_args + _comp_initialize -- "$@" || return case $prev in --help | --version | -[hV]) return ;; --status-file) - _filedir + _comp_compgen_filedir return ;; esac - local cmd i + local cmd="" has_cmd="" i for ((i = 1; i < cword; i++)); do if [[ ${words[i]} != -* && ${words[i - 1]} != --status-file ]]; then cmd=${words[i]} + has_cmd=set break fi done case ${cmd-} in check | run) - _filedir '@(py|pyi)' + _comp_compgen_filedir '@(py|pyi)' return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help return fi - if [[ ! -v cmd ]]; then - local cmds=$($1 --help 2>&1 | - command sed -ne '/positional arguments/{p;n;p;q}' | + if [[ ! $has_cmd ]]; then + local cmds=$("$1" --help 2>&1 | + command sed -ne '/positional arguments/{p;n;p;q;}' | command sed -ne 's/{\(.*\)}/\1/p') - COMPREPLY=($(IFS="," compgen -W '$cmds' -- "$cur")) + _comp_compgen -F , -- -W '$cmds' return fi } && - complete -F _dmypy dmypy + complete -F _comp_cmd_dmypy dmypy # ex: filetype=sh |