diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:18 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:18 +0000 |
commit | f2621414ee5f2f601424c22f00e207903e3b6104 (patch) | |
tree | 56a856dafd1ca684bb23263cacaa723ee4f404fc /completions/carton | |
parent | Adding debian version 1:2.11-8. (diff) | |
download | bash-completion-f2621414ee5f2f601424c22f00e207903e3b6104.tar.xz bash-completion-f2621414ee5f2f601424c22f00e207903e3b6104.zip |
Merging upstream version 1:2.12.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | completions/carton | 60 |
1 files changed, 37 insertions, 23 deletions
diff --git a/completions/carton b/completions/carton index 5d700c8..7f99c90 100644 --- a/completions/carton +++ b/completions/carton @@ -1,81 +1,95 @@ # carton(3pm) completion -*- shell-script -*- -_carton_commands() +_comp_cmd_carton__commands() { - local cmds=$("${1:-carton}" usage 2>&1 | + local cmds=$("$1" usage 2>&1 | command sed -ne '/.*command.* is one of/{n;p;q;}') - COMPREPLY+=($(IFS="$IFS," compgen -W "$cmds" -- "$cur")) + _comp_compgen -aF $' \t\n,' -- -W "$cmds" } -_carton_command_help() +_comp_cmd_carton__command_help() { - local help=$(PERLDOC_PAGER=cat PERLDOC=-otext "${1:-carton}" -h $2 2>&1) - COMPREPLY+=($(compgen -W '$help' -- "$cur")) + local help=$(PERLDOC_PAGER=cat PERLDOC=-otext "$1" -h "$2" 2>&1) + _comp_compgen -a -- -W '$help' } -_carton() +_comp_cmd_carton() { - local cur prev words cword split - _init_completion -s || return + local cur prev words cword was_split comp_args + _comp_initialize -s -- "$@" || return - local i command + local i command="" has_command="" for ((i = 1; i < cword; i++)); do case ${words[i]} in -*) ;; *) command=${words[i]} + has_command=set break ;; esac done - if [[ ! -v command ]]; then - _carton_commands "$1" + if [[ ! $has_command ]]; then + _comp_cmd_carton__commands "$1" return fi case $prev in - --version | -v) - return - ;; - --help | -h) - [[ -n $command ]] || _carton_commands "$1" + --version | --help | -[vh]) return ;; --cpanfile) if [[ $command == install ]]; then - _filedir + _comp_compgen_filedir return fi ;; --path) if [[ $command == install ]]; then - _filedir -d + _comp_compgen_filedir -d return fi ;; --without) if [[ $command == install ]]; then local phases="configure build test runtime develop" - COMPREPLY+=($(compgen -W '$phases' -- "$cur")) + _comp_compgen -a -- -W '$phases' return fi ;; esac - $split && return + [[ $was_split ]] && return if [[ $cur == -* ]]; then [[ $command == @(help|usage) ]] || COMPREPLY=(--help) - _carton_command_help "$1" $command + _comp_cmd_carton__command_help "$1" "$command" fi case $command in + exec) + # skip all the options --, -v, etc. and identify the command name + # position. + for ((i++; i < cword; i++)); do + case ${words[i]} in + --) + ((i++)) + break + ;; + -*) ;; + *) break ;; + esac + done + + _comp_command_offset "$i" + return + ;; show | update) : # TODO modules completion ;; esac } && - complete -F _carton carton + complete -F _comp_cmd_carton carton # ex: filetype=sh |