summaryrefslogtreecommitdiffstats
path: root/completions/apt-build
blob: 5327780de7f4423d661173fdf191a0e12dab285a (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
# Debian apt-build(1) completion                           -*- shell-script -*-

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

    local special="" i
    for ((i = 1; i < cword; i++)); do
        if [[ ${words[i]} == @(install|remove|source|info|clean) ]]; then
            special=${words[i]}
            break
        fi
    done

    if [[ $special ]]; then
        case $special in
            install | source | info)
                _comp_compgen -x apt-cache packages
                ;;
            remove)
                _comp_compgen -x dpkg installed_packages
                ;;
        esac
        return
    fi

    case $prev in
        --patch | --build-dir | --repository-dir)
            _comp_compgen_filedir
            return
            ;;
        -h | --help)
            return
            ;;
    esac

    if [[ $cur == -* ]]; then
        _comp_compgen -- -W '--help --show-upgraded -u --build-dir
            --repository-dir --build-only --build-command --reinstall --rebuild
            --remove-builddep --no-wrapper --purge --patch --patch-strip -p
            --yes -y --version -v --no-source'

    else
        _comp_compgen -- -W 'update upgrade install remove source dist-upgrade
            world clean info clean-build update-repository'
    fi

} &&
    complete -F _comp_cmd_apt_build apt-build

# ex: filetype=sh