diff options
author | Clint Adams <clint@users.sourceforge.net> | 2005-04-16 20:22:44 +0000 |
---|---|---|
committer | Clint Adams <clint@users.sourceforge.net> | 2005-04-16 20:22:44 +0000 |
commit | 89f3361e60ec1da55f53a632a98d834b9f27e2cf (patch) | |
tree | 725f9b422aa3c92b24d3abb5743a7ed0c681784e /Completion/Unix/Command/_tla | |
parent | d6089cc8b17ed7d33850bb9075a9c6771fe120d6 (diff) | |
download | zsh-89f3361e60ec1da55f53a632a98d834b9f27e2cf.tar.gz zsh-89f3361e60ec1da55f53a632a98d834b9f27e2cf.tar.xz zsh-89f3361e60ec1da55f53a632a98d834b9f27e2cf.zip |
* 21147: factor out some common code from _tla and _baz, and fix some breakage
from 21075.
Diffstat (limited to 'Completion/Unix/Command/_tla')
-rw-r--r-- | Completion/Unix/Command/_tla | 117 |
1 files changed, 5 insertions, 112 deletions
diff --git a/Completion/Unix/Command/_tla b/Completion/Unix/Command/_tla index 0951cc749..876f9dcf3 100644 --- a/Completion/Unix/Command/_tla +++ b/Completion/Unix/Command/_tla @@ -23,30 +23,19 @@ fi # completion functions (( $+functions[_tla_archives] )) || -_tla_archives () { - local expl completions library name_arg='-n' - if [[ -n $argv[(r)--library] ]]; then - library='library-' - # remove parameter from $@ before calling compadd - argv[(r)--library]=() - name_arg= - fi - completions=($(_call_program tla $TLA ${library:-}archives $name_arg)) - _description -V archives expl "${library:-}archives" - compadd "$@" "$expl[@]" -- "$completions[@]" -} +_tla_archives () { _arch_archives tla "$@" } (( $+functions[_tla_categories] )) || -_tla_categories () { _tla_namespace 1 "$argv[@]" } +_tla_categories () { _arch_namespace tla 1 "$argv[@]" } (( $+functions[_tla_branches] )) || -_tla_branches () {_tla_namespace 2 "$argv[@]" } +_tla_branches () {_arch_namespace tla 2 "$argv[@]" } (( $+functions[_tla_versions] )) || -_tla_versions () { _tla_namespace 3 "$argv[@]" } +_tla_versions () { _arch_namespace tla 3 "$argv[@]" } (( $+functions[_tla_revisions] )) || -_tla_revisions () { _tla_namespace 4 "$argv[@]" } +_tla_revisions () { _arch_namespace tla 4 "$argv[@]" } (( $+functions[_tla_local_revisions] )) || _tla_local_revisions () { @@ -59,102 +48,6 @@ _tla_local_revisions () { # Should complete based on -A, -R, -d } -(( $+functions[_tla_namespace] )) || -_tla_namespace () { #double as arch_namespace_categories -# takes an integer argument specifying how many components: -# 1: category -# 2: branch -# 3: version -# 4: revision - local suffix expl archive=`$TLA my-default-archive 2> /dev/null` - local trailing_dashes=0 - [[ -n $argv[(r)--trailing-dashes] ]] && trailing_dashes=1 - local library - [[ -n $argv[(r)--library] ]] && library='library-'; - local exclude_library_revisions=0 - [[ -n $argv[(r)--exclude-library-revisions] ]] && exclude_library_revisions=1 - - if [ $1 -gt 1 ] || (( trailing_dashes )); then - suffix=(-q -S --) - fi - if [[ $PREFIX = */* ]]; then - compset -P '*/' - archive=${IPREFIX%/*} - _description -V categories expl "${library:-}categories in $archive" - compadd $suffix "$expl[@]" `$TLA ${library:-}categories -A $archive` - elif [ -z $IPREFIX ]; then - local index=$(( words[(i)-A] + 1 )) - (( index < CURRENT )) || index=$(( words[(i)--archive] + 1 )) - (( index < CURRENT )) && archive=$words[$index] - - if [ $archive ]; then - _description -V categories expl "${library:-}categories in $archive" - compadd "$expl[@]" $suffix `$TLA ${library:-}categories -A $archive` - fi - - _tla_archives -S / ${library:+--library} - fi - if [ $archive ] && [ $1 -gt 1 ] && [[ $PREFIX != *@* ]] \ - && [[ $PREFIX = *--* ]]; then - #this match could be better - _tla_namespace_branches $(($1 - 1)) - fi -} - -(( $+functions[_tla_namespace_branches] )) || -_tla_namespace_branches () { - local suffix expl - if [ $1 -gt 1 ] || (( $trailing_dashes )); then - suffix=(-q -S --) - fi - if [[ $IPREFIX != *-- ]]; then - compset -P 1 '*--' - local category=${IPREFIX%--} - _description -V branches expl "${library:-}branches" - compadd $suffix "$expl[@]" \ - ${${(@)$($TLA ${library:-}branches -A $archive $category)}##*--} - fi - if [ $1 -gt 1 ] && [[ $IPREFIX = *-- ]] && [[ $PREFIX = *--* ]]; then - _tla_namespace_versions $(($1 - 1)) - fi -} - -(( $+functions[_tla_namespace_versions] )) || -_tla_namespace_versions () { - local suffix expl - if [ $1 -gt 1 ]; then - suffix=(-q -S --) - fi - if [[ $IPREFIX != *--*-- ]] || [[ $IPREFIX != */*--*-- ]]; then - compset -P 1 '*--' - local branch=${IPREFIX%--} - _description -V versions expl "${library:-}versions" - compadd $suffix "$expl[@]" \ - ${${(@)$($TLA ${library:-}versions -A $archive $branch)}##*--} - fi - if [ $1 -gt 1 ] && [[ $IPREFIX = *--*-- ]] && ([[ $IPREFIX = */*--*-- ]] \ - || [[ $PREFIX != */* ]]) && [[ $PREFIX = *--* ]]; then - _tla_namespace_revisions - fi -} - -(( $+functions[_tla_namespace_revisions] )) || -_tla_namespace_revisions () { - local expl - if [[ $IPREFIX != *--*--*-- ]] || [[ $IPREFIX != */*--*--*-- ]]; then - compset -P 1 '*--' - local version=${IPREFIX%--} - _description -V revisions expl "${library:-}revisions" - local completions c - completions=( - ${${(@)$($TLA ${library:-}revisions -A $archive $version)}##*--} - ) - (( exclude_library_revisions )) && \ - foreach c ($($TLA library-revisions -A $archive $version)); do completions[(r)$c]=(); done - compadd "$expl[@]" -a completions - fi -} - (( $+functions[_tla_config] )) || _tla_config () { |