summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Hill <dirtyepic@gentoo.org>2012-11-02 23:52:22 -0600
committerRyan Hill <dirtyepic@gentoo.org>2012-11-02 23:52:22 -0600
commitda5fba4f2bc976c573bf658e05fe0f854796dbf6 (patch)
treef5ea4da7f680d8dd6d673ff58e19cf4c96d6a400
parentCreate annotated tags. (diff)
downloadgentoo-bashcomp-da5fba4f2bc976c573bf658e05fe0f854796dbf6.tar.gz
gentoo-bashcomp-da5fba4f2bc976c573bf658e05fe0f854796dbf6.tar.bz2
gentoo-bashcomp-da5fba4f2bc976c573bf658e05fe0f854796dbf6.zip
Make layman completion work again.
Sometime in the last three years the output of layman changed and broke the overlay parsing. Also updated options, fixed handling of opts containing "=" with bash-4, and cleaned up a bunch of stuff.
-rw-r--r--layman93
1 files changed, 45 insertions, 48 deletions
diff --git a/layman b/layman
index 0463f9a..40219f8 100644
--- a/layman
+++ b/layman
@@ -9,66 +9,63 @@
# Originally written by: Peter "Link" Sterk <link@penguindevelopment.org>
-have layman && {
- _layman()
- {
- local cur prev opts r_overlays l_overlays
- opts="-a --add -d --delete -s --sync -i --info -S --sync-all -L --list \
- -l --list-local -f --fetch -n --nofetch -p --priority -c --config \
- -o --overlays -v --verbose -q --quiet -N --nocolor -Q --quietness \
- -k --nocheck --debug --debug-level --debug-verbose --debug-methods \
- --debug-classes --debug-variables --debug-class-vars --debug-nocolor"
+have layman &&
+_layman() {
+ local cur prev opts r_overlays l_overlays splitopt
- r_overlays="$(layman -LkN 2>/dev/null | grep '(source' | awk '{print $2}')"
- l_overlays="$(layman -lkN 2>/dev/null | grep '(source' | awk '{print $2}')"
- ls_overlays="${l_overlays} ALL"
+ COMPREPLY=()
- COMPREPLY=()
+ opts="--version -h --help -a --add -d --delete -s --sync -i --info
+ -S --sync-all -L --list -l --list-local -n --nofetch -p --priority
+ -c --config -O --overlay_defs -o --overlays -v --verbose -q --quiet
+ -N --nocolor -Q --quietness -W --width -k --nocheck --debug-level"
+ r_overlays="$(layman -LkNq 2>/dev/null | grep -v '^$' | cut -d' ' -f3)"
+ l_overlays="$(layman -lkNq 2>/dev/null | grep -v '^$' | cut -d' ' -f3)"
+ splitopt=false
- cur="${COMP_WORDS[COMP_CWORD]}"
- prev="${COMP_WORDS[COMP_CWORD-1]}"
+ _get_comp_words_by_ref -n = cur prev
+ _split_longopt && splitopt=true
- if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]]
- then
- COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+ case ${prev} in
+ --version|-h|--help|-W|--width|-o|--overlays)
+ # these end processing or require an arg we can't complete on
return 0
- fi
-
- case "${prev}" in
- -a|--add)
- COMPREPLY=($(compgen -W "${r_overlays}" -- ${cur}))
- return 0
;;
- -d|--delete)
- COMPREPLY=($(compgen -W "${l_overlays}" -- "${cur}"))
- return 0
+ -a|--add|-i|--info)
+ COMPREPLY=( $(compgen -W "${r_overlays}" -- "${cur}") )
+ return 0
;;
- -s|--sync)
- COMPREPLY=($(compgen -W "${ls_overlays}" -- "${cur}"))
- return 0
+ -d|--delete)
+ COMPREPLY=( $(compgen -W "${l_overlays}" -- "${cur}") )
+ return 0
;;
- -i|--info)
- COMPREPLY=($(compgen -W "${r_overlays}" -- "${cur}"))
- return 0
+ -s|--sync)
+ COMPREPLY=( $(compgen -W "${l_overlays} ALL" -- "${cur}") )
+ return 0
;;
- -p|--priority)
- COMPREPLY=($(compgen -W "$(seq 0 100)" -- "${cur}"))
- return 0
+ -p|--priority)
+ # this seems excessive
+ COMPREPLY=( $(compgen -W "$(seq 0 100)" -- "${cur}") )
+ return 0
;;
- -Q|--quietness)
- COMPREPLY=($(compgen -W "$(seq 0 4)" -- "${cur}"))
- return 0
+ -Q|--quietness)
+ COMPREPLY=( $(compgen -W "$(seq 0 4)" -- "${cur}") )
+ return 0
;;
- --debug-level)
- COMPREPLY=($(compgen -W "$(seq 0 10)" -- "${cur}"))
- return 0
+ --debug-level)
+ COMPREPLY=( $(compgen -W "$(seq 0 10)" -- "${cur}") )
+ return 0
;;
- --debug-verbose)
- COMPREPLY=($(compgen -W "$(seq 1 3)" -- "${cur}"))
- return 0
+ -c|--config|-O|--overlay_defs)
+ _filedir
+ return 0
;;
- esac
- }
- complete -F _layman layman
+ esac
+
+ $splitopt && return 0
+
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
}
+complete -F _layman layman
+
# vim: ft=sh:et:ts=4:sw=4:tw=80