]>
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) | |
b6d1f536 ER |
26 | local spec |
27 | _builder_get_spec | |
07666488 | 28 | COMPREPLY=( $( compgen -W '$( git tag )' -- "$cur" ) ) |
4427bdf1 ER |
29 | return 0 |
30 | ;; | |
31 | --with|--without) | |
b6d1f536 ER |
32 | local spec |
33 | _builder_get_spec | |
90d32772 | 34 | $1 -nn -ncs --show-avail-bconds $spec |
4427bdf1 ER |
35 | return 0 |
36 | ;; | |
329e9cf2 | 37 | esac |
5b8f2ffc | 38 | |
4427bdf1 ER |
39 | if [[ $cur == -* ]]; then |
40 | COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) | |
329e9cf2 | 41 | else |
8a71a198 | 42 | _filedir spec |
5b8f2ffc | 43 | fi |
4427bdf1 | 44 | } && |
bb7982d3 | 45 | complete -F _builder builder |