summaryrefslogtreecommitdiffstats
path: root/scripts/debsign.bash_completion
blob: a7b72fba8e816085251a1b8e1ff1aff201ad4c31 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# /usr/share/bash-completion/completions/debsign
# Bash command completion for ‘debsign(1)’.
# Documentation: ‘bash(1)’, section “Programmable Completion”.

shopt -s progcomp

_have _debsign_completion &&
_debsign_completion () {
    COMPREPLY=()

    local cur="${COMP_WORDS[COMP_CWORD]}"
    local prev="${COMP_WORDS[COMP_CWORD-1]}"

    local options=(
        -h --help --version
        -r -m -e -k
        -a -t --multi
        -p --debs-dir
        -S
        --re-sign --no-re-sign
        --no-conf --noconf
    )

    case "$prev" in
        -r)
            # The option requires a non-option argument here, but we
            # have no feasible way to generate auto-completion matches
            # for ‘username@remotehost’. Use an empty set.
            local host_options=""
            COMPREPLY=( $(compgen -W "$host_options" -- "$cur") )
            ;;

        -m|-e)
            # The previous option requires an argument, but we
            # have no feasible way to generate auto-completion matches
            # for a maintainer identifier. Use an empty set.
            local maintainer_options=""
            COMPREPLY=( $(compgen -W "$maintainer_options" -- "$cur") )
            ;;

        -k)
            # Provide completions for GnuPG secret key IDs.
            local keyid_options=$(
                gpg --fixed-list-mode --with-colons --fingerprint \
                    --list-secret-keys \
                    | awk -F':' '/^sec/{print $5}' )
            COMPREPLY=( $(
                    compgen -W "$keyid_options" | grep "^${cur:-.}"
                ) )
            ;;

        -a)
            # Provide completions for system architecture identifiers.
            local arch_options=$(dpkg-architecture --list-known)
            COMPREPLY=( $(compgen -W "$arch_options" -- "$cur") )
            ;;

        -t)
            # The previous option requires an argument, but we
            # have no feasible way to generate auto-completion matches
            # for a GNU system type identifier. Use an empty set.
            local type_options=""
            COMPREPLY=( $(compgen -W "$type_options" -- "$cur") )
            ;;

        -p)
            # Provide completions for available commands.
            COMPREPLY=( $(compgen -A command -- "$cur") )
            ;;

        --debs-dir)
            # Provide completions for existing directory paths.
            COMPREPLY=( $(compgen -o dirnames -A directory -- "$cur") )
            ;;

        *)
            COMPREPLY=( $(
                    compgen -G "${cur}*.changes"
                    compgen -G "${cur}*.buildinfo"
                    compgen -G "${cur}*.dsc"
                    compgen -G "${cur}*.commands"
                    compgen -W "${options[*]}" -- "$cur"
                ) )
            compopt -o filenames
            compopt -o plusdirs
            ;;
    esac

    return 0

} && complete -F _debsign_completion debsign


# Local variables:
# coding: utf-8
# mode: shell-script
# indent-tabs-mode: nil
# End:
# vim: fileencoding=utf-8 filetype=sh expandtab shiftwidth=4 :