3 _arch_namespace () { #double as arch_namespace_categories
6 # takes an integer argument specifying how many components:
11 local suffix expl archive=`$ARCHCMD my-default-archive 2> /dev/null`
12 local trailing_dashes=0
13 [[ -n $argv[(r)--trailing-dashes] ]] && trailing_dashes=1
15 [[ -n $argv[(r)--library] ]] && library='library-';
16 local exclude_library_revisions=0
17 [[ -n $argv[(r)--exclude-library-revisions] ]] && exclude_library_revisions=1
19 if [ $1 -gt 1 ] || (( trailing_dashes )); then
22 if [[ $PREFIX = */* ]]; then
25 _description -V categories expl "${library:-}categories in $archive"
26 compadd $suffix "$expl[@]" `$ARCHCMD ${library:-}categories $archive`
27 elif [ -z $IPREFIX ]; then
28 local index=$(( words[(i)-A] + 1 ))
29 (( index < CURRENT )) || index=$(( words[(i)--archive] + 1 ))
30 (( index < CURRENT )) && archive=$words[$index]
33 _description -V categories expl "${library:-}categories in $archive"
34 compadd "$expl[@]" $suffix `$ARCHCMD ${library:-}categories $archive`
37 _arch_archives "$ARCHCMD" -S / ${library:+--library}
39 if [ $archive ] && [ $1 -gt 1 ] && [[ $PREFIX != *@* ]] \
40 && [[ $PREFIX = *--* ]]; then
41 #this match could be better
42 _arch_namespace_branches "$ARCHCMD" $(($1 - 1))
46 (( $+functions[_arch_namespace_branches] )) ||
47 _arch_namespace_branches () {
51 if [ $1 -gt 1 ] || (( $trailing_dashes )); then
54 if [[ $IPREFIX != *-- ]]; then
56 local category=${IPREFIX%--}
57 _description -V branches expl "${library:-}branches"
58 compadd $suffix "$expl[@]" \
59 ${${(@)$($ARCHCMD ${library:-}branches $category)}##*--}
61 if [ $1 -gt 1 ] && [[ $IPREFIX = *-- ]] && [[ $PREFIX = *--* ]]; then
62 _arch_namespace_versions "${ARCHCMD}" $(($1 - 1))
66 (( $+functions[_arch_namespace_versions] )) ||
67 _arch_namespace_versions () {
74 if [[ $IPREFIX != *--*-- ]] || [[ $IPREFIX != */*--*-- ]]; then
76 local branch=${IPREFIX%--}
77 _description -V versions expl "${library:-}versions"
78 compadd $suffix "$expl[@]" \
79 ${${(@)$($ARCHCMD ${library:-}versions $branch)}##*--}
81 if [ $1 -gt 1 ] && [[ $IPREFIX = *--*-- ]] && ([[ $IPREFIX = */*--*-- ]] \
82 || [[ $PREFIX != */* ]]) && [[ $PREFIX = *--* ]]; then
83 _arch_namespace_revisions "${ARCHCMD}"
87 (( $+functions[_arch_namespace_revisions] )) ||
88 _arch_namespace_revisions () {
91 if [[ $IPREFIX != *--*--*-- ]] || [[ $IPREFIX != */*--*--*-- ]]; then
93 local version=${IPREFIX%--}
94 _description -V revisions expl "${library:-}revisions"
97 ${${(@)$($ARCHCMD ${library:-}revisions $version)}##*--}
99 (( exclude_library_revisions )) && \
100 foreach c ($($ARCHCMD library-revisions $version)); do completions[(r)$c]=(); done
101 compadd "$expl[@]" -a completions