summaryrefslogtreecommitdiffstats
path: root/completions/reportbug
blob: 30c4647bb4e7b1f1c820c771798cce98bed50fd8 (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
# bash completion for (Debian) reportbug                   -*- shell-script -*-

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

    local noargopts='!(-*|*[CefKHPsoiATjVuQtBS]*)'
    # shellcheck disable=SC2254
    case $prev in
        --class | --header | --pseudo-header | --mirror | --list-cc | \
            --subject | --http_proxy | --proxy | --email | --realname | \
            --smtpuser | --smtppasswd | --replyto | --reply-to | \
            --justification | --package-version | --body | --body-file | \
            --timeout | --max-attachment-size | --envelope-from | \
            -${noargopts}[CHPsjV])
            return
            ;;
        --filename | --include | --mta | --output | --attach | -[fioA])
            _comp_compgen_filedir
            return
            ;;
        --keyid | -${noargopts}K)
            _comp_compgen_split -- "$(
                IFS=:
                gpg --list-keys --with-colons 2>/dev/null |
                    while read -ra row; do
                        [[ ${row[0]} == [ps]ub && ${row[11]} == *s* ]] &&
                            printf '%s\n' "${row[4]}"
                    done
            )"
            return
            ;;
        --tag | --ui | --interface | --type | --bts | --severity | --mode | -${noargopts}[TutBS])
            _comp_compgen_split -- "$("$1" "$prev" help 2>&1 |
                command sed -ne '/^[[:space:]]/p')"
            return
            ;;
        --editor | --mua | --mbox-reader-cmd | -${noargopts}e)
            _comp_compgen_commands
            return
            ;;
        --from-buildd)
            _comp_compgen_split -S "_" -- "$(apt-cache dumpavail |
                _comp_awk -F ' ' '$1 == "Source:" && !uniq[$2]++ { print $2 }')"
            return
            ;;
        --smtphost)
            _comp_compgen_known_hosts -- "$cur"
            return
            ;;
        --draftpath)
            _comp_compgen_filedir -d
            return
            ;;
    esac

    [[ $was_split ]] && return

    if [[ $cur == -* ]]; then
        _comp_compgen_help
        [[ ${COMPREPLY-} == -*= ]] && compopt -o nospace
        return
    fi

    _comp_compgen -- -W 'wnpp boot-floppies kernel bugs.debian.org
        cdimage.debian.org general installation-reports listarchives
        lists.debian.org mirrors nm.debian.org press project qa.debian.org
        release-notes security.debian.org tech-ctte upgrade-reports
        www.debian.org'
    _comp_compgen -ax apt-cache packages
    _comp_compgen -a filedir
} &&
    complete -F _comp_cmd_reportbug reportbug

# ex: filetype=sh