summaryrefslogtreecommitdiffstats
path: root/Auxiliary/bash-completion/cpack
blob: 05e0e93ec76c058d4c16f1f7fa05f20768b3f112 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# bash completion for cpack(1)                             -*- shell-script -*-

_cpack()
{
    local cur prev words cword
    if type -t _init_completion >/dev/null; then
        _init_completion -n = || return
    else
        # manual initialization for older bash completion versions
        COMPREPLY=()
        cur="${COMP_WORDS[COMP_CWORD]}"
        prev="${COMP_WORDS[COMP_CWORD-1]}"
    fi

    case "$prev" in
        -G)
            COMPREPLY=( $( compgen -W '$( cpack --help 2>/dev/null |
                sed -e "1,/^Generators/d" -e "s|^ *\([^ ]*\) .*$|\1|" \
                2>/dev/null )' -- "$cur" ) )
            return
            ;;
        -C)
            COMPREPLY=( $( compgen -W 'Debug Release RelWithDebInfo
                MinSizeRel' -- "$cur" ) )
            return
            ;;
        -D)
            [[ $cur == *=* ]] && return # no completion for values
            COMPREPLY=( $( compgen -W '$( cpack --help-variable-list \
                2>/dev/null | grep -v "^cpack version " )' -S = -- "$cur" ) )
            compopt -o nospace
            return
            ;;
        -P|-R|--vendor)
            # argument required but no completions available
            return
            ;;
        -B)
            _filedir -d
            return
            ;;
        --config)
            _filedir
            return
            ;;
        --help-command)
            COMPREPLY=( $( compgen -W '$( cpack --help-command-list 2>/dev/null|
                grep -v "^cpack version " )' -- "$cur" ) )
            return
            ;;
        --help-variable)
            COMPREPLY=( $( compgen -W '$( cpack --help-variable-list \
                2>/dev/null | grep -v "^cpack version " )' -- "$cur" ) )
            return
            ;;
    esac

    if [[ "$cur" == -* ]]; then
        COMPREPLY=( $(compgen -W '$( _parse_help "$1" --help )' -- ${cur}) )
        [[ $COMPREPLY == *= ]] && compopt -o nospace
        [[ $COMPREPLY ]] && return
    fi

    _filedir
} &&
complete -F _cpack cpack

# ex: ts=4 sw=4 et filetype=sh