~ubuntu-branches/ubuntu/vivid/debtags/vivid

« back to all changes in this revision

Viewing changes to bash-completion

  • Committer: Package Import Robot
  • Author(s): Enrico Zini, Michael Vogt, Enrico Zini
  • Date: 2013-10-25 12:41:25 UTC
  • Revision ID: package-import@ubuntu.com-20131025124125-ytl4xarlmdyiuzjb
Tags: 1.12
[ Michael Vogt ]
* Install files in python3-debtagshw

[ Enrico Zini ]
* Build with new wibble

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
_debtags()
7
7
{
8
8
        local cur prev options
9
 
        
 
9
 
 
10
        # Helper function to keep up with ":"
 
11
        _get_comp_words_by_ref -n : cur prev words cword
 
12
 
10
13
        COMPREPLY=()
11
 
        cur=${COMP_WORDS[COMP_CWORD]}
12
 
        prev=${COMP_WORDS[COMP_CWORD-1]}
13
14
        options='cat check diff dumpavail grep help \
14
15
                mkpatch search \
15
16
                show submit tag tagcat tagsearch \
16
17
                tagshow update vocfilter'
17
 
        
18
 
        for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
19
 
                case ${COMP_WORDS[i]} in
 
18
 
 
19
        for (( i=0; i < ${#words[@]}; i++ )); do
 
20
                case ${words[i]} in
20
21
                # commands requiring a filename
21
22
                check|mkpatch|diff|submit)
22
23
                        _filedir
23
24
                        return 0
24
25
                        ;;
25
 
                
 
26
 
26
27
                tag)
27
28
                        # the tag command expects one of the following parameters: 
28
29
                        # add, rm, ls
37
38
                                return 0
38
39
                                ;;
39
40
                        *)
40
 
                                if [[ -n "${COMP_WORDS[COMP_CWORD-2]}" ]]; then
41
 
                                        case ${COMP_WORDS[COMP_CWORD-2]} in
 
41
                                if [[ -n "${words[cword-2]}" ]]; then
 
42
                                        case ${words[cword-2]} in
42
43
                                                # add and rm are special: they need a tag after the package name
43
44
                                                #
44
45
                                                # TODO: filter out unneeded tags from the add and rm completion input
68
69
                                COMPREPLY=( $( compgen -W '--invert-match --quiet' -- $cur ) )
69
70
                                return 0
70
71
                        fi
 
72
 
71
73
                        COMPREPLY=( $( grep "^Tag: $cur" /var/lib/debtags/vocabulary |cut -b 6- ) )
 
74
 
 
75
                        # Helper function to keep up with ":"
 
76
                        __ltrim_colon_completions "$cur"
72
77
                        return 0
73
78
                        ;;
74
79
                # commands requiring an expression
75
 
                # TODO: Understand how to implement it. :)
76
 
                # We should be able to complete while quoting; at the moment
77
 
                # behave like the 'single tag' case.
78
 
                # ex: x11::<tab><tab> becomes
79
 
                # $cur="::"
80
 
                # $prev="x11"
81
 
                # instead of $cur="x11::"
82
 
                # This is a known problem with bash-completion
83
80
                grep|search)
84
81
                        if [[ "$prev" == "grep" && "$cur" == -* ]]; then
85
82
                                COMPREPLY=( $( compgen -W '--invert-match --quiet' -- $cur ) )
86
83
                                return 0
87
84
                        fi
 
85
 
88
86
                        COMPREPLY=( $( grep "^Tag: $cur" /var/lib/debtags/vocabulary |cut -b 6- ) )
 
87
 
 
88
                        # Helper function to keep up with ":"
 
89
                        __ltrim_colon_completions "$cur"
89
90
                        return 0
90
91
                        ;;
91
92
                cat)
104
105
                return 0
105
106
        fi
106
107
        
107
 
        if [[ "$COMP_CWORD" == 1 ]]; then
 
108
        if [[ "$cword" == 1 ]]; then
108
109
                COMPREPLY=( $( compgen -W "$options" -- $cur ) )
109
110
                return 0
110
111
        fi