]>
Commit | Line | Data |
---|---|---|
07666488 | 1 | # PLD Linux builder(1) script completion |
d98fe2df | 2 | |
b6d1f536 ER |
3 | # get active spec file from commandline |
4 | # caller should make $spec local variable | |
5 | # TODO: it gets it wrong if some option arg is found before spec itself | |
6 | _builder_get_spec() | |
7 | { | |
8 | local i | |
9 | spec= | |
10 | for (( i=1; i < ${#words[@]}-1; i++ )); do | |
11 | if [[ ${words[i]} != -* ]]; then | |
12 | spec=${words[i]} | |
13 | break | |
14 | fi | |
15 | done | |
16 | [[ ! -f $spec ]] && return 0 | |
17 | } | |
18 | ||
5b8f2ffc ER |
19 | _builder() |
20 | { | |
4427bdf1 ER |
21 | local cur prev words cword |
22 | _init_completion || return | |
5b8f2ffc | 23 | |
4427bdf1 ER |
24 | case $prev in |
25 | -r) | |
07666488 | 26 | COMPREPLY=( $( compgen -W '$( git tag )' -- "$cur" ) ) |
4427bdf1 ER |
27 | return 0 |
28 | ;; | |
29 | --with|--without) | |
ce4b36ee | 30 | local spec bconds |
b6d1f536 | 31 | _builder_get_spec |
ce4b36ee ER |
32 | bconds=$( |
33 | awk ' | |
34 | /^%changelog/ { exit } | |
35 | /^%bcond_with/{ | |
36 | print $2 | |
37 | }' $spec | |
38 | ) | |
39 | COMPREPLY=( $( compgen -W "$bconds" -- "$cur" ) ) | |
4427bdf1 ER |
40 | return 0 |
41 | ;; | |
329e9cf2 | 42 | esac |
5b8f2ffc | 43 | |
4427bdf1 ER |
44 | if [[ $cur == -* ]]; then |
45 | COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) | |
329e9cf2 | 46 | else |
8a71a198 | 47 | _filedir spec |
5b8f2ffc | 48 | fi |
4427bdf1 | 49 | } && |
bb7982d3 | 50 | complete -F _builder builder |