summaryrefslogtreecommitdiffstats
path: root/completions/unpack200
blob: 3724f37fb00b348e63323e2920ebccc0463a1f9d (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
# unpack200(1) completion                                  -*- shell-script -*-

_comp_cmd_unpack200()
{
    local cur prev words cword was_split comp_args
    _comp_initialize -s -- "$@" || return

    local noargopts='!(-*|*[Hl]*)'
    # shellcheck disable=SC2254
    case $prev in
        --help | --version | -${noargopts}[?hVJ])
            return
            ;;
        --deflate-hint | -${noargopts}H)
            _comp_compgen -- -W 'true false keep'
            return
            ;;
        --log-file | -${noargopts}l)
            _comp_compgen -- -W '-'
            _comp_compgen -a filedir log
            return
            ;;
    esac

    [[ $was_split ]] && return

    # Check if a pack or a jar was already given.
    local word pack="" jar=""
    for word in "${words[@]:1}"; do
        case $word in
            *.pack | *.pack.gz) pack=set ;;
            *.jar) jar=set ;;
        esac
    done

    if [[ ! $pack ]]; then
        if [[ $cur == -* ]]; then
            _comp_compgen -- -W '--deflate-hint= --remove-pack-file --verbose
                --quiet --log-file= --help --version'
            [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
        else
            _comp_compgen_filedir 'pack?(.gz)'
        fi
    elif [[ ! $jar ]]; then
        _comp_compgen_filedir jar
    fi
} &&
    complete -F _comp_cmd_unpack200 unpack200

# ex: filetype=sh