From 52d16f8a397b247a1e2e662827507b7f86d77fc6 Mon Sep 17 00:00:00 2001 From: Tim Harder Date: Fri, 19 Dec 2014 18:20:38 -0800 Subject: array formatting, whitespace consistency, and other minor cleanups --- src/_genlop | 85 ++++++++++++++++++++++++++++----------------------------- src/_gentoolkit | 9 ++++-- src/_portage | 36 ++++++++++++++---------- 3 files changed, 68 insertions(+), 62 deletions(-) diff --git a/src/_genlop b/src/_genlop index 92c844b..420c8c5 100644 --- a/src/_genlop +++ b/src/_genlop @@ -3,73 +3,70 @@ #genlop 0.30.8 _genlop () { -local prev1="$words[CURRENT-1]" prev2="$words[CURRENT-2]" days months arg single state lstate -days=(monday tuesday wednesday thursday friday saturday sunday) -months=(january february march april may june july august september october november december) -arg=( --current -c --time -t --gmt -g --info -i --file -f --rsync -r --unmerge -u --date --search -s --list -l ) -single=( --current -c --pretend -p --help -h --version -v ) + local prev1="$words[CURRENT-1]" prev2="$words[CURRENT-2]" days months arg single state lstate + days=(monday tuesday wednesday thursday friday saturday sunday) + months=(january february march april may june july august september october november december) + arg=( --current -c --time -t --gmt -g --info -i --file -f --rsync -r --unmerge -u --date --search -s --list -l ) + single=( --current -c --pretend -p --help -h --version -v ) [[ ${prev2} == (1st|2nd|3rd|4th|5th) ]] && - compadd in\ $months && return 0 + compadd $months && return 0 [[ ${prev1} == ([2-9]|[1-9][0-9]*) && ${prev2} != \ - (january|february|march|april|may|june|july|august|september|october|november|december) ]] && + (january|february|march|april|may|june|july|august|september|october|november|december) ]] && _values '' 'days ago' 'months ago' 'years ago' 'weeks ago' && return 0 [[ ${prev1} == (1) && ${prev2} != \ - (january|february|march|april|may|june|july|august|september|october|november|december) ]] && + (january|february|march|april|may|june|july|august|september|october|november|december) ]] && _values '' 'day ago' 'month ago' 'year ago' 'week ago' && return 0 case "$prev1" in last) _values '' month week - compadd $days && return 0 - ;; + compadd $days && return 0 + ;; 1st|2nd|3rd|4th|5th) - compadd $days && return 0 - ;; + compadd $days && return 0 + ;; january|february|march|april|may|june|july|august|september|october|november|december) - compadd {1..31} && return 0 - ;; + compadd {1..31} && return 0 + ;; --date) _message 'enter number for more options or use mm/dd/yyyy format' - _values '' \ - last yesterday 1st 2nd 3rd 4th 5th - _alternative \ - '*:*:_days' '*:*:_months' && return 0 - ;; + _values '' last yesterday 1st 2nd 3rd 4th 5th + _alternative '*:*:_days' '*:*:_months' && return 0 + ;; --file|-f) _arguments '*:logfile:_files' && return 0 - ;; + ;; *) - _arguments \ - "($single $arg *)"{--current,-c}"[display the current merge in action]" \ - "($single)*--date[specify date of event]:date:->date" \ - "($single)*-f[specify the logfile to use]:logfile:_files" \ - "($single --gmt -g)"{--gmt,-g}"[display time in GMT/UTC format (default is local time)]" \ - "($single $arg *)"{--help,-h}"[display help information]" \ - "($single --info -i --list -l)"{--info,-i}"[print brief summary about installed ebuild]" \ - "($single --search -s --info -i --list -l *)"{--list,-l}"[list merge history]" \ - "(--nocolor -n)"{--nocolor,-n}"[disable colored output]" \ - "($single $arg *)"{--pretend,-p}"[estimate build time of a piped emerge -p]" \ - "($single --search -s --info -i --time -t --unmerge -u --rsync -r *)"{--rsync,-r}"[display rsync history]" \ - "($single --rsync -r --search -s --list -l *)"{--search,-s}"[select ebuilds matching the provided regular expression]:pattern:" \ - "($single --time -t)"{--time,-t}"[display merge time]" \ - "($single --rsync -r --unmerge -u)"{--unmerge,-u}"[display when packages have been unmerged]" \ - "($single $arg *)"{--version,-v}"[display version information]" \ - "($single)*:package:_gentoo_packages available" - ;; + _arguments \ + "($single $arg *)"{--current,-c}"[display the current merge in action]" \ + "($single)*--date[specify date of event]:date:->date" \ + "($single)*-f[specify the logfile to use]:logfile:_files" \ + "($single --gmt -g)"{--gmt,-g}"[display time in GMT/UTC format (default is local time)]" \ + "($single $arg *)"{--help,-h}"[display help information]" \ + "($single --info -i --list -l)"{--info,-i}"[print brief summary about installed ebuild]" \ + "($single --search -s --info -i --list -l *)"{--list,-l}"[list merge history]" \ + "(--nocolor -n)"{--nocolor,-n}"[disable colored output]" \ + "($single $arg *)"{--pretend,-p}"[estimate build time of a piped emerge -p]" \ + "($single --search -s --info -i --time -t --unmerge -u --rsync -r *)"{--rsync,-r}"[display rsync history]" \ + "($single --rsync -r --search -s --list -l *)"{--search,-s}"[select ebuilds matching the provided regular expression]:pattern:" \ + "($single --time -t)"{--time,-t}"[display merge time]" \ + "($single --rsync -r --unmerge -u)"{--unmerge,-u}"[display when packages have been unmerged]" \ + "($single $arg *)"{--version,-v}"[display version information]" \ + "($single)*:package:_gentoo_packages available" + ;; esac while [[ -n "$state" ]]; do lstate=$state state='' case "$lstate" in - date) _message 'enter number for more options or use mm/dd/yyyy format' - _values '' \ - last yesterday 1st 2nd 3rd 4th 5th - _alternative \ - ':*:_days' ':*:_months' && return 0 - ;; - esac + date) + _message 'enter number for more options or use mm/dd/yyyy format' + _values '' last yesterday 1st 2nd 3rd 4th 5th + _alternative ':*:_days' ':*:_months' && return 0 + ;; + esac done } diff --git a/src/_gentoolkit b/src/_gentoolkit index 0b0d956..903e4b6 100644 --- a/src/_gentoolkit +++ b/src/_gentoolkit @@ -22,6 +22,7 @@ _packages () { _euse () { local state tmp start_args suboptions_args + start_args=( {'(--help)-h','(-h)--help'}'[show help]' {'(--version)-v','(-v)--version'}'[show version]' @@ -34,10 +35,12 @@ _euse () { {'(--prune)-P','(-P)--prune'}'[alias for --remove]' {'(--package)-p','(-p)--package'}'[used with -E, -D, and -R to apply to a specific package only]' ) + suboptions_args=( {'(--global)-g','(-g)--global'}'[show only global use flags]' {'(--local)-l','(-l)--local'}'[show only local use flags]' ) + if (( CURRENT == 2 )); then _arguments -s $start_args elif (( CURRENT == 3 )); then @@ -236,10 +239,12 @@ _eclean_wrapper () { '(: -)'{-h,--help}'[show help]' '(: -)'{-V,--version}'[show version]' ) + dist_opts=( '(-s,--size-limit)'{-s,--size-limit}'[do not delete disfiles bigger than ]:size:_eclean_size' '(-f,--fetch-restricted)'{-f,--fetch-restricted}'[protect fetch-restricted files]' ) + # XXX: If you add options here make sure that it'll work. # since there isn't any option *right* now, $pkg_opts # is never used. @@ -258,11 +263,9 @@ _eclean_wrapper () { # global_opts and packages|distfiles otherwhise. if (( $words[(I)(packages)] )); then # Currently no options so return 0 - #_values "packages options" $pkg_opts && return 0 elif (( $words[(I)(distfiles)] )); then - _values "distfiles options" $dist_opts && - return 0 + _values "distfiles options" $dist_opts && return 0 else _arguments -s $global_opts # complete packages|distfiles only if CURRENT-1 don't need an arg diff --git a/src/_portage b/src/_portage index efa3c0e..7610937 100644 --- a/src/_portage +++ b/src/_portage @@ -12,7 +12,6 @@ # Still TODO: # xpak -# Stuff for ebuild _ebuild () { if (( CURRENT == 2 )); then _files -g \*.ebuild @@ -38,7 +37,6 @@ _ebuild () { 'manifest[Updates the manifest file for the package.]' \ 'rpm[Builds a RedHat RPM package]' fi - } _quickpkg () { @@ -65,24 +63,30 @@ _quickpkg () { fi } -# Stuff for emerge - _emerge () { - local nopkg_opts all noask_opts bopts install_args common_args profiles + local noask_opts nopkg_opts bopts all common_args install_args profiles - noask_opts=(-p -a --pretend --ask --regen --info --search -s --searchdesc \ - -S --version -V --help -h --metadata --check-news) + noask_opts=( + -p -a --pretend --ask --regen --info --search -s --searchdesc + -S --version -V --help -h --metadata --check-news + ) - nopkg_opts=(--resume --skipfirst -c --clean -h --help --depclean --info \ - --metadata -P --prune --regen -s --search -S --searchdesc --sync -C \ - --unmerge -V --version -i --inject --list-sets --deselect --check-news) + nopkg_opts=( + --resume --skipfirst -c --clean -h --help --depclean --info + --metadata -P --prune --regen -s --search -S --searchdesc --sync -C + --unmerge -V --version -i --inject --list-sets --deselect --check-news + ) - bopts=($nopkg_opts -b --buildpkg -B --buildpkgonly -G --getbinpkgonly -g \ - --getbinpkg -k --usepkg -K --usepkgonly --fetch-all-uri -f -F --fetchonly) + bopts=( + $nopkg_opts -b --buildpkg -B --buildpkgonly -G --getbinpkgonly -g + --getbinpkg -k --usepkg -K --usepkgonly --fetch-all-uri -f -F --fetchonly + ) - all=($bopts -l --changelog --columns --deep -D --emptytree -e --newuse \ - --noconfmem --nodeps -O --noreplace -n --oneshot -1 -o --onlydeps --tree -t \ - -u --update -U --upgradeonly --config) + all=( + $bopts -l --changelog --columns --deep -D --emptytree -e --newuse + --noconfmem --nodeps -O --noreplace -n --oneshot -1 -o --onlydeps --tree -t + -u --update -U --upgradeonly --config + ) common_args=( "($noask_opts --sync)"{-p,--pretend}"[Simply display what would be done]" @@ -102,6 +106,7 @@ _emerge () { "--moo[Have you mooed today?]" "(--jobs)--jobs[Number of packages to build simultaneously]:jobs:({1.."${#${$(