1
1
# bts completion -*- shell-script -*-
2
2
3
- # List bug numbers from bugs cache in ~/.devscripts_cache/bts
4
- # TODO:API: rename per conventions, rework to use vars rather than outputting
5
- _cached_bugs ()
3
+ # Generate bug numbers from bugs cache in ~/.devscripts_cache/bts
4
+ # TODO:API: generator
5
+ _comp_cmd_bts__cached_bugs ()
6
6
{
7
- [[ -d $HOME /.devscripts_cache/bts ]] &&
7
+ [[ -d $HOME /.devscripts_cache/bts ]] || return 1
8
+ local bugs=$(
8
9
find " $HOME /.devscripts_cache/bts" -maxdepth 1 \
9
10
-name " ${cur} [0-9]*.html" \
10
11
-printf " %f\n" | cut -d' .' -f1
12
+ )
13
+ _comp_compgen -aR -- -W ' $bugs'
11
14
}
12
15
13
- # List APT source packages prefixed with "src:"
14
- # TODO:API: rename per conventions, rework to use vars rather than outputting
15
- _src_packages_with_prefix ()
16
+ # Generate APT source packages prefixed with "src:"
17
+ # TODO:API: generator
18
+ _comp_cmd_bts__src_packages_with_prefix ()
16
19
{
17
- ppn=${cur: 4} # partial package name, after stripping "src:"
18
- compgen -P " src:" -W ' $(_comp_xfunc apt-cache sources "$ppn")' \
19
- -- " $ppn "
20
+ local ppn=${cur: 4} # partial package name, after stripping "src:"
21
+ _comp_compgen -ac " $ppn " -- -P " src:" -W ' $(_comp_xfunc apt-cache sources "$ppn")'
20
22
}
21
23
22
24
_comp_cmd_bts ()
@@ -26,9 +28,9 @@ _comp_cmd_bts()
26
28
27
29
case $prev in
28
30
show | bugs)
29
- COMPREPLY=( $( compgen - W ' release-critical RC from: tag:
30
- usertag: ' -- " $cur " ) $( _cached_bugs )
31
- $( _src_packages_with_prefix ) )
31
+ _comp_compgen -- - W ' release-critical RC from: tag: usertag: '
32
+ _comp_cmd_bts__cached_bugs
33
+ _comp_cmd_bts__src_packages_with_prefix
32
34
return
33
35
;;
34
36
select)
@@ -38,8 +40,8 @@ _comp_cmd_bts()
38
40
return
39
41
;;
40
42
status)
41
- COMPREPLY=( $( compgen - W ' file: fields: verbose' -- " $cur " )
42
- $( _cached_bugs ) )
43
+ _comp_compgen -- - W ' file: fields: verbose'
44
+ _comp_cmd_bts__cached_bugs
43
45
return
44
46
;;
45
47
block | unblock)
@@ -57,23 +59,24 @@ _comp_cmd_bts()
57
59
return
58
60
;;
59
61
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)
60
- COMPREPLY=($( _cached_bugs) )
62
+ COMPREPLY=()
63
+ _comp_cmd_bts__cached_bugs
61
64
return
62
65
;;
63
66
package)
64
67
COMPREPLY=($( _comp_xfunc apt-cache packages) )
65
68
return
66
69
;;
67
70
cache)
68
- COMPREPLY=($( _comp_xfunc apt-cache packages)
69
- $( _src_packages_with_prefix )
70
- $( compgen - W ' from: release-critical RC' -- " $cur " ) )
71
+ COMPREPLY=($( _comp_xfunc apt-cache packages) )
72
+ _comp_cmd_bts__src_packages_with_prefix
73
+ _comp_compgen -a -- - W ' from: release-critical RC'
71
74
return
72
75
;;
73
76
cleancache)
74
- COMPREPLY=($( _comp_xfunc apt-cache packages)
75
- $( _src_packages_with_prefix )
76
- $( compgen - W ' from: tag: usertag: ALL' -- " $cur " ) )
77
+ COMPREPLY=($( _comp_xfunc apt-cache packages) )
78
+ _comp_cmd_bts__src_packages_with_prefix
79
+ _comp_compgen -a -- - W ' from: tag: usertag: ALL'
77
80
return
78
81
;;
79
82
user)
0 commit comments