diff options
author | Ryan Hill <dirtyepic@gentoo.org> | 2012-10-21 17:03:48 -0600 |
---|---|---|
committer | Ryan Hill <dirtyepic@gentoo.org> | 2012-10-21 18:55:01 -0600 |
commit | 6a9662fd54d22f36062279886686e84b79928f2d (patch) | |
tree | 4c93c09e4dfbecaac866eaac75f9064aa4e28a01 | |
parent | Rewrite repoman completion. (diff) | |
download | gentoo-bashcomp-6a9662fd54d22f36062279886686e84b79928f2d.tar.gz gentoo-bashcomp-6a9662fd54d22f36062279886686e84b79928f2d.tar.bz2 gentoo-bashcomp-6a9662fd54d22f36062279886686e84b79928f2d.zip |
Add modelines and retab.
-rw-r--r-- | gentoo | 199 | ||||
-rw-r--r-- | layman | 115 | ||||
-rw-r--r-- | repoman | 87 |
3 files changed, 200 insertions, 201 deletions
@@ -1937,107 +1937,106 @@ complete -F _metagen metagen have rc-service && { _rc_service() { - local cur prev numwords opts - local words i x filename - local action actionpos - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - numwords=${#COMP_WORDS[*]} - - if [[ ${prev} == '>' || ${prev} == '<' ]] ; then - COMPREPLY=($(compgen -f -- ${cur})) - return 0 - fi - - # find action - for x in ${COMP_LINE} ; do - if [[ ${x} =~ --(list|exists|resolve) ]] || \ - [[ ${x} =~ -(l|e|r) ]] - then - action=${x} - break - fi - done - if [[ -n ${action} ]]; then - for ((i = 0; i < ${numwords}; i++ )); do - if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then - actionpos=${i} - break - fi - done - - for ((i = 1; i < ${numwords}; i++ )); do - if [[ ! ${COMP_WORDS[$i]} == -* ]]; then - break - fi - done - fi - - if [[ ${COMP_CWORD} -eq 3 ]]; then - return 1 - fi - - # check if an option was typed - if [[ ${cur} == -* ]]; then - if [[ ${cur} == --* ]]; then - opts="--list --exists --resolve" - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - elif [[ ${cur} == -* ]]; then - opts="-l -e -r" - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - fi - - - # NOTE: This slows things down! - # (Adapted from bash_completion by Ian Macdonald <ian@caliban.org>) - # This removes any options from the list of completions that have - # already been specified on the command line. - COMPREPLY=($(echo "${COMP_WORDS[@]}" | \ - (while read -d ' ' i; do - [[ -z ${i} ]] && continue - # flatten array with spaces on either side, - # otherwise we cannot grep on word boundaries of - # first and last word - COMPREPLY=" ${COMPREPLY[@]} " - # remove word from list of completions - COMPREPLY=(${COMPREPLY/ ${i%% *} / }) - done - echo ${COMPREPLY[@]}))) - - return 0 - # if no option typed - else - if [[ ${COMP_CWORD} -eq 1 ]]; then # if first word typed - words="`rc-service -l | grep ^${cur}`" # complete for init scripts - COMPREPLY=($(for i in ${words} ; do \ - [[ ${i} == ${cur}* ]] && echo ${i} ; \ - done)) - return 0 - elif [[ ${COMP_CWORD} -eq 2 ]] && [[ ${prev} != -* ]]; then # if second word typed and we didn't type in a function - filename=`rc-service -r ${prev}` - opts=`cat ${filename} | grep "^\w*()" | sed "s/().*$//"` # Greps the functions included in the init script - if [[ "x${opts}" == "x" ]] ; then # if no options found loosen the grep algorhythm - opts=`cat ${filename} | grep "\w*()" | sed "s/().*$//"` - fi - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - fi - fi - if [[ ${action} == '--exists' ]] || [[ ${action} == '-e' ]] || \ - [[ ${action} == '--resolve' ]] || [[ ${action} == '-r' ]]; then - words="`rc-service -l | grep ^${cur}`" - COMPREPLY=($(for i in ${words} ; do \ - [[ ${i} == ${cur}* ]] && echo ${i} ; \ - done)) - return 0 - fi - + local cur prev numwords opts + local words i x filename + local action actionpos + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + numwords=${#COMP_WORDS[*]} + + if [[ ${prev} == '>' || ${prev} == '<' ]] ; then + COMPREPLY=($(compgen -f -- ${cur})) + return 0 + fi + + # find action + for x in ${COMP_LINE} ; do + if [[ ${x} =~ --(list|exists|resolve) ]] || \ + [[ ${x} =~ -(l|e|r) ]] + then + action=${x} + break + fi + done + if [[ -n ${action} ]]; then + for ((i = 0; i < ${numwords}; i++ )); do + if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then + actionpos=${i} + break + fi + done + + for ((i = 1; i < ${numwords}; i++ )); do + if [[ ! ${COMP_WORDS[$i]} == -* ]]; then + break + fi + done + fi + + if [[ ${COMP_CWORD} -eq 3 ]]; then + return 1 + fi + + # check if an option was typed + if [[ ${cur} == -* ]]; then + if [[ ${cur} == --* ]]; then + opts="--list --exists --resolve" + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + elif [[ ${cur} == -* ]]; then + opts="-l -e -r" + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + fi + + + # NOTE: This slows things down! + # (Adapted from bash_completion by Ian Macdonald <ian@caliban.org>) + # This removes any options from the list of completions that have + # already been specified on the command line. + COMPREPLY=($(echo "${COMP_WORDS[@]}" | \ + (while read -d ' ' i; do + [[ -z ${i} ]] && continue + # flatten array with spaces on either side, + # otherwise we cannot grep on word boundaries of + # first and last word + COMPREPLY=" ${COMPREPLY[@]} " + # remove word from list of completions + COMPREPLY=(${COMPREPLY/ ${i%% *} / }) + done + echo ${COMPREPLY[@]}))) + + return 0 + # if no option typed + else + if [[ ${COMP_CWORD} -eq 1 ]]; then # if first word typed + words="`rc-service -l | grep ^${cur}`" # complete for init scripts + COMPREPLY=($(for i in ${words} ; do \ + [[ ${i} == ${cur}* ]] && echo ${i} ; \ + done)) + return 0 + elif [[ ${COMP_CWORD} -eq 2 ]] && [[ ${prev} != -* ]]; then # if second word typed and we didn't type in a function + filename=`rc-service -r ${prev}` + opts=`cat ${filename} | grep "^\w*()" | sed "s/().*$//"` # Greps the functions included in the init script + if [[ "x${opts}" == "x" ]] ; then # if no options found loosen the grep algorhythm + opts=`cat ${filename} | grep "\w*()" | sed "s/().*$//"` + fi + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + fi + fi + if [[ ${action} == '--exists' ]] || [[ ${action} == '-e' ]] || \ + [[ ${action} == '--resolve' ]] || [[ ${action} == '-r' ]]; then + words="`rc-service -l | grep ^${cur}`" + COMPREPLY=($(for i in ${words} ; do \ + [[ ${i} == ${cur}* ]] && echo ${i} ; \ + done)) + return 0 + fi + return 0 } complete -F _rc_service rc-service } - -# vim: set ft=sh tw=80 sw=4 et : +# vim: ft=sh:et:ts=4:sw=4:tw=80 @@ -2,7 +2,7 @@ # # $Id$ # -# Copyright 1999-2009 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License, v2 or later # # Originally licensed as 'public-domain' @@ -10,66 +10,65 @@ 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" + _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" - 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" + 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=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" - if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] - then - COMPREPLY=($(compgen -W "${opts}" -- ${cur})) - return 0 - fi + if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] + then + COMPREPLY=($(compgen -W "${opts}" -- ${cur})) + 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 - ;; - -s|--sync) - COMPREPLY=($(compgen -W "${ls_overlays}" -- "${cur}")) - return 0 - ;; - -i|--info) - COMPREPLY=($(compgen -W "${r_overlays}" -- "${cur}")) - return 0 - ;; - -p|--priority) - COMPREPLY=($(compgen -W "$(seq 0 100)" -- "${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-verbose) - COMPREPLY=($(compgen -W "$(seq 1 3)" -- "${cur}")) - return 0 - ;; - esac - } - complete -F _layman layman + case "${prev}" in + -a|--add) + COMPREPLY=($(compgen -W "${r_overlays}" -- ${cur})) + return 0 + ;; + -d|--delete) + COMPREPLY=($(compgen -W "${l_overlays}" -- "${cur}")) + return 0 + ;; + -s|--sync) + COMPREPLY=($(compgen -W "${ls_overlays}" -- "${cur}")) + return 0 + ;; + -i|--info) + COMPREPLY=($(compgen -W "${r_overlays}" -- "${cur}")) + return 0 + ;; + -p|--priority) + COMPREPLY=($(compgen -W "$(seq 0 100)" -- "${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-verbose) + COMPREPLY=($(compgen -W "$(seq 1 3)" -- "${cur}")) + return 0 + ;; + esac + } + complete -F _layman layman } - -# vim: set ft=sh tw=80 sw=4 et : +# vim: ft=sh:et:ts=4:sw=4:tw=80 @@ -10,55 +10,56 @@ _repoman() { - local cur prev opts modes split=false + local cur prev opts modes split=false - COMPREPLY=() - opts="$(_parse_help ${COMP_WORDS[0]}) --commitmsg --commitmsgfile" - modes="ci commit fix full help manifest manifest-check scan" + COMPREPLY=() + opts="$(_parse_help ${COMP_WORDS[0]}) --commitmsg --commitmsgfile" + modes="ci commit fix full help manifest manifest-check scan" - _get_comp_words_by_ref -n = cur prev - _split_longopt && split=true + _get_comp_words_by_ref -n = cur prev + _split_longopt && split=true - case $prev in - -h|--help|help|-m|--commitmsg|-V|--version) - return 0 - ;; - --commitmsgfile) - _filedir - return 0 - ;; - --digest|--if-modified) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) - return 0 - ;; - --echangelog) - COMPREPLY=( $(compgen -W 'y n force' -- "$cur") ) - return 0 - ;; - --mode) - COMPREPLY=( $(compgen -W "${modes}" -- "$cur") ) - return 0 - ;; - --vcs) - COMPREPLY=( $(compgen -W 'cvs svn git bzr hg' -- "$cur") ) - return 0 - ;; - esac + case $prev in + -h|--help|help|-m|--commitmsg|-V|--version) + return 0 + ;; + --commitmsgfile) + _filedir + return 0 + ;; + --digest|--if-modified) + COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + return 0 + ;; + --echangelog) + COMPREPLY=( $(compgen -W 'y n force' -- "$cur") ) + return 0 + ;; + --mode) + COMPREPLY=( $(compgen -W "${modes}" -- "$cur") ) + return 0 + ;; + --vcs) + COMPREPLY=( $(compgen -W 'cvs svn git bzr hg' -- "$cur") ) + return 0 + ;; + esac - $split && return 0 + $split && return 0 - case $cur in - -*) - COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) - return 0 - ;; - *) - COMPREPLY=( $(compgen -W "$modes" -- "$cur") ) - return 0 - ;; - esac + case $cur in + -*) + COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) + return 0 + ;; + *) + COMPREPLY=( $(compgen -W "$modes" -- "$cur") ) + return 0 + ;; + esac - return 0 + return 0 } complete -F _repoman repoman +# vim: ft=sh:et:ts=4:sw=4:tw=80 |