summaryrefslogtreecommitdiffstats
path: root/completions/xz
blob: 73958c50da1abf34c357f70c61c525adbc84074c (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
# xz(1) completion                                         -*- shell-script -*-

_xz()
{
    local cur prev words cword split
    _init_completion -s || return

    local xspec="*.@(xz|lzma|txz|tlz)"

    case $prev in
        --decompress | --list | --test | -!(-*)[dlt]*)
            xspec="!"$xspec
            ;;
        --files | --files0)
            _filedir
            return
            ;;
        --check | -!(-*)C)
            COMPREPLY=($(compgen -W 'crc32 crc64 sha256 none' -- "$cur"))
            return
            ;;
        --format | -!(-*)F)
            COMPREPLY=($(compgen -W 'auto xz lzma raw' -- "$cur"))
            return
            ;;
        --threads | -!(-*)T)
            COMPREPLY=($(compgen -W "{0..$(_ncpus)}" -- "$cur"))
            return
            ;;
        --memlimit | --memlimit-compress | --memlimit-decompress | --memory | \
            --suffix | --delta | --lzma1 | --lzma2 | -!(-*)[MS])
            return
            ;;
        --help | --long-help | --version | --info-memory | -!(-*)[hHV])
            return
            ;;
    esac

    $split && return

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

    _tilde "$cur" || return

    local IFS=$'\n'
    compopt -o filenames
    COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur"))
} &&
    complete -F _xz xz pxz

# ex: filetype=sh