summaryrefslogtreecommitdiff
path: root/completions/bts
blob: d535d13ed0473ce781e304c673594940cb6c5b15 (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
100
101
102
103
104
105
106
107
108
109
110
111
112
# bts completion                                      -*- shell-script -*-

# List bug numbers from bugs cache in ~/.devscripts_cache/bts
_cached_bugs()
{
    [[ -d $HOME/.devscripts_cache/bts ]] &&
        find $HOME/.devscripts_cache/bts -maxdepth 1 -name "${cur}[0-9]*.html" \
            -printf "%f\n" | cut -d'.' -f1
}

# List APT source packages prefixed with "src:"
_src_packages_with_prefix()
{
    ppn=${cur:4} # partial package name, after stripping "src:"
    compgen -P "src:" -W '$(_xfunc apt-cache _apt_cache_sources "$ppn")' \
        -- "$ppn"
}

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

    case $prev in
        show | bugs)
            COMPREPLY=($(compgen -W 'release-critical RC from: tag:
                usertag:' -- "$cur") $(_cached_bugs)
            $(_src_packages_with_prefix))
            return
            ;;
        select)
            COMPREPLY=($(compgen -W 'package: source: maintainer: submitter:
                severity: status: tag: owner: correspondent: affects: bugs:
                users:  archive:' -- "$cur"))
            return
            ;;
        status)
            COMPREPLY=($(compgen -W 'file: fields: verbose' -- "$cur")
            $(_cached_bugs))
            return
            ;;
        block | unblock)
            COMPREPLY=($(compgen -W 'by with' -- "$cur"))
            return
            ;;
        severity)
            COMPREPLY=($(compgen -W 'wishlist minor normal important serious
                grave critical' -- "$cur"))
            return
            ;;
        limit)
            COMPREPLY=($(compgen -W 'submitter date subject msgid package
                source tag severity owner affects archive' -- "$cur"))
            return
            ;;
        clone | "done" | reopen | archive | unarchive | retitle | summary | submitter | found | notfound | fixed | notfixed | merge | forcemerge | unmerge | claim | unclaim | forwarded | notforwarded | owner | noowner | subscribe | unsubscribe | reportspam | spamreport | affects | usertag | usertags | reassign | tag | tags)
            COMPREPLY=($(_cached_bugs))
            return
            ;;
        package)
            COMPREPLY=($(_xfunc apt-cache _apt_cache_packages))
            return
            ;;
        cache)
            COMPREPLY=($(_xfunc apt-cache _apt_cache_packages)
            $(_src_packages_with_prefix)
            $(compgen -W 'from: release-critical RC' -- "$cur"))
            return
            ;;
        cleancache)
            COMPREPLY=($(_xfunc apt-cache _apt_cache_packages)
            $(_src_packages_with_prefix)
            $(compgen -W 'from: tag: usertag: ALL' -- "$cur"))
            return
            ;;
        user)
            # non-predicible arguments
            COMPREPLY=()
            return
            ;;
        :)
            # Chances are that "src:<src_package>" is being completed
            # COMP_WORDS would be: "bts cleancache src : <partial_pkg_name>"
            pos=$((COMP_CWORD - 2))
            if [[ $pos -gt 0 && ${COMP_WORDS[pos]} == "src" ]]; then
                COMPREPLY=($(_xfunc apt-cache _apt_cache_src_packages))
                return
            fi
            ;;
    esac

    $split && return

    COMPREPLY=($(compgen -W '--offline --online --no-offline
        --no-action --cache --no-cache --cache-mode --cache-delay --mbox
        --mailreader --cc-addr --use-default-cc --no-use-default-cc
        --sendmail --mutt --no-mutt --smtp-host --smtp-username
        --smtp-helo --bts-server --force-refresh --no-force-refresh
        --only-new --include-resolved --no-include-resolved --no-ack --ack
        --interactive --force-interactive --no-interactive --quiet
        --no-conf --noconf
        show bugs select status clone done reopen archive unarchive retitle
        summary submitter reassign found notfound fixed notfixed block unblock
        merge forcemerge unmerge tag tags affects user usertag usertags claim
        unclaim severity forwarded notforwarded package limit owner noowner
        subscribe unsubscribe reportspam spamreport cache cleancache version
        help' -- "$cur"))

} &&
    complete -F _bts bts

# ex: filetype=sh