[packages/bash-completion] - modern bash-completion setup - use parse_help to retrieve options - make with/without not checkout
glen
glen at pld-linux.org
Sun Aug 12 19:32:22 CEST 2012
commit 4427bdf1c220201102552d1c4359285280b13aea
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Sun Aug 12 20:28:53 2012 +0300
- modern bash-completion setup
- use parse_help to retrieve options
- make with/without not checkout package, and use current program not builder from $PATH
builder.bash-completion | 45 +++++++++++++++------------------------------
1 file changed, 15 insertions(+), 30 deletions(-)
---
diff --git a/builder.bash-completion b/builder.bash-completion
index 8f08167..15c2a15 100644
--- a/builder.bash-completion
+++ b/builder.bash-completion
@@ -9,40 +9,25 @@ _builder_spec_tags() {
_builder()
{
- local cur prev first
+ local cur prev words cword
+ _init_completion || return
- COMPREPLY=()
- cur=`_get_cword`
- prev=${COMP_WORDS[COMP_CWORD-1]}
-
- case "$prev" in
- -@(g|--get))
- _filedir
- return 0
- ;;
- -r)
- local spec=*.spec
- _builder_spec_tags "$cur" "$spec"
- return 0
- ;;
- --with|--without)
- ./builder --show-avail-bconds automake.spec
- return 0
- ;;
+ case $prev in
+ -r)
+ local spec=*.spec
+ _builder_spec_tags "$cur" "$spec"
+ return 0
+ ;;
+ --with|--without)
+ $1 -nn -ncs --show-avail-bconds automake.spec
+ return 0
+ ;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $( compgen -W '
- -5 -a5 -n5 -D -V -a -b -ba -bb -bp -bc -bi -bl -bs -B -c -cf -d -g
- -h -l -m -nc -ncs -nd -nm -nu -ns -ns0 -nn -ske -q -r -A -R -RB
- -FRB -sd -sdp -sf -sp -su -T -Tvs -Ts -Tv -Tp -tt -ir -v -u -un
- -U -Upi -np
- --with --without
- ' -- $cur ) )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
else
_filedir spec
fi
-
- return 0
-}
+} &&
complete -F _builder builder
More information about the pld-cvs-commit
mailing list