aboutsummaryrefslogtreecommitdiff
path: root/bash_completion.d/pbuilder
blob: 8a9450067958a4a3e87a9c22df9fdc7d89619974 (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
69
70
71
72
73
74
75
76
77
78
# Debian GNU/Linux cowbuilder(1) completion
# Copyright 2007 Cyril Brulebois <cyril.brulebois@enst-bretagne.fr>
#
# This script can be distributed under the same license as the
# cowdancer or bash packages.
#
# adapted to pbuilder, the license is GPLv2 or later.
# Copyright 2007 Junichi Uekawa <dancer@debian.org>

_pbuilder()
{
    local cur prev command i

    COMPREPLY=()
    _get_comp_words_by_ref cur prev


    if [[ $COMP_CWORD -eq 1 ]]; then
        COMPREPLY=( $( compgen -W '--create --update --build --login --execute \
            --dumpconfig create update build login execute dumpconfig' -- "$cur" ) )
        return 0
    fi

    _expand || return 0

    # find the last option flag
    if [[ $cur != -* ]]; then
        i=$COMP_CWORD
        while [[ $prev != -* && $i != 2 ]]; do
            i=$((i-1))
            prev=${COMP_WORDS[i-1]}
        done
    fi

    command=${COMP_WORDS[1]}

    case $prev in
        --basetgz)
            # tgz file completion
            _filedir 'tgz'
            return 0
            ;;
        --configfile|--logfile)
            # Any file
            _filedir
            return 0
            ;;
        --buildplace|--buildresults)
            # Any directory
            _filedir -d
            return 0
            ;;
        *)
            # Provide available flags
            COMPREPLY=( $( compgen -W '--allow-untrusted --basetgz --buildplace --mirror \
                --othermirror --http-proxy --distribution --architecture --components \
                --buildresult --aptcache --removepackages --extrapackages --configfile \
                --hookdir --debemail --debbuildopts --logfile --pkgname-logfile \
                --aptconfdir --timeout --override-config  --binary-arch \
                --preserve-buildplace --bindmounts --debug --twice --autocleanaptcache \
                --compressprog --debootstrapopts --save-after-login --save-after-exec \
                --debootstrap' \
                -- "$cur" ) )
            if [[ $prev = @(--aptcache|--hookdir) ]]; then
                # Optionally provide a directory
                _filedir -d
            fi
            if [[ $cur != -* && $command == @(--build|build) ]]; then
                # dsc file completion
                _filedir "dsc"
            fi
            return 0
            ;;
    esac

    return 0
} &&
complete -F _pbuilder pbuilder