summaryrefslogtreecommitdiffstats
path: root/Completion/Base/_arguments
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-11-03 13:47:39 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-11-03 13:47:39 +0000
commit97f02ffe63909c84cb9771d20a73ebec55f49589 (patch)
tree997db6027bc486992bdab800ed53404512446919 /Completion/Base/_arguments
parentzsh-workers/8519 (diff)
downloadzsh-97f02ffe63909c84cb9771d20a73ebec55f49589.tar
zsh-97f02ffe63909c84cb9771d20a73ebec55f49589.tar.gz
zsh-97f02ffe63909c84cb9771d20a73ebec55f49589.tar.bz2
zsh-97f02ffe63909c84cb9771d20a73ebec55f49589.tar.lz
zsh-97f02ffe63909c84cb9771d20a73ebec55f49589.tar.xz
zsh-97f02ffe63909c84cb9771d20a73ebec55f49589.tar.zst
zsh-97f02ffe63909c84cb9771d20a73ebec55f49589.zip
zsh-workers/8520
Diffstat (limited to 'Completion/Base/_arguments')
-rw-r--r--Completion/Base/_arguments168
1 files changed, 87 insertions, 81 deletions
diff --git a/Completion/Base/_arguments b/Completion/Base/_arguments
index ca8f42c61..04d588c49 100644
--- a/Completion/Base/_arguments
+++ b/Completion/Base/_arguments
@@ -154,122 +154,127 @@ fi
if comparguments -i "$compconfig[autodescribe_options]" "$@"; then
local nm="$compstate[nmatches]" action noargs aret expl local
local next direct odirect equal single match matched ws tmp1 tmp2
+ local prios tags opts
- if ! comparguments -D descr action; then
+ if comparguments -D descr action; then
+ if comparguments -O next direct odirect equal; then
+ opts=yes
+ _tags -f "$funcstack[2]" argument option
+ else
+ _tags -f "$funcstack[2]" argument
+ fi
+ else
if comparguments -a; then
noargs='no more arguments'
else
noargs='no arguments'
fi
- fi
+ comparguments -O next direct odirect equal || return 1
- while true; do
+ opts=yes
+ _tags -f "$funcstack[2]" option
+ fi
- if [[ -z "$noargs" || -n "$matched" ]]; then
- _description expl "$descr"
+ while _tags; do
+ while true; do
+ if [[ "$tags" = *:argument* ]]; then
+ _description expl "$descr"
- if [[ "$action" = -\>* ]]; then
- comparguments -W line opt_args
- state="${${action[3,-1]##[ ]#}%%[ ]#}"
- compstate[restore]=''
- aret=yes
- else
- if [[ -z "$local" ]]; then
- local line
- typeset -A opt_args
- local=yes
- fi
+ if [[ "$action" = -\>* ]]; then
+ comparguments -W line opt_args
+ state="${${action[3,-1]##[ ]#}%%[ ]#}"
+ compstate[restore]=''
+ aret=yes
+ else
+ if [[ -z "$local" ]]; then
+ local line
+ typeset -A opt_args
+ local=yes
+ fi
- comparguments -W line opt_args
+ comparguments -W line opt_args
- if [[ "$action" = \ # ]]; then
+ if [[ "$action" = \ # ]]; then
- # An empty action means that we should just display a message.
+ # An empty action means that we should just display a message.
- [[ -n "$matched" ]] && compadd -n -Q -S '' -s "$SUFFIX" - "$PREFIX"
- mesg="$descr"
+ [[ -n "$matched" ]] && compadd -n -Q -S '' -s "$SUFFIX" - "$PREFIX"
+ mesg="$descr"
- elif [[ "$action" = \(\(*\)\) ]]; then
+ elif [[ "$action" = \(\(*\)\) ]]; then
- # ((...)) contains literal strings with descriptions.
+ # ((...)) contains literal strings with descriptions.
- eval ws\=\( "${action[3,-3]}" \)
+ eval ws\=\( "${action[3,-3]}" \)
- _describe -c "$cmd" "$descr" ws -M "$match"
+ _describe -c "$cmd" -f "$funcstack[2]" "$descr" ws -M "$match"
- elif [[ "$action" = \(*\) ]]; then
+ elif [[ "$action" = \(*\) ]]; then
- # Anything inside `(...)' is added directly.
+ # Anything inside `(...)' is added directly.
- compadd "$expl[@]" - ${=action[2,-2]}
- elif [[ "$action" = \{*\} ]]; then
+ compadd "$expl[@]" - ${=action[2,-2]}
+ elif [[ "$action" = \{*\} ]]; then
- # A string in braces is evaluated.
+ # A string in braces is evaluated.
- eval "$action[2,-2]"
+ eval "$action[2,-2]"
- elif [[ "$action" = \ * ]]; then
+ elif [[ "$action" = \ * ]]; then
- # If the action starts with a space, we just call it.
+ # If the action starts with a space, we just call it.
- ${(e)=~action}
- else
+ ${(e)=~action}
+ else
- # Otherwise we call it with the description-arguments built above.
+ # Otherwise we call it with the description-arguments built above.
- action=( $=action )
- ${(e)action[1]} "$expl[@]" ${(e)~action[2,-1]}
+ action=( $=action )
+ ${(e)action[1]} "$expl[@]" ${(e)~action[2,-1]}
+ fi
fi
fi
- fi
-
- if [[ -z "$matched" ]] &&
- comparguments -O next direct odirect equal &&
- [[ ( ( nm -eq compstate[nmatches] || -n "$noargs" ) &&
- -z "$aret" && -z "$mesg" ) ||
- -z "$compconfig[option_prefix]" ||
- "$compconfig[option_prefix]" = *\!${cmd}* ||
- "$PREFIX" = [-+]* ]]; then
+ if [[ "$tags" = *:option* &&
+ ( "$tags" != *\[*prefix*\]* || "$PREFIX" = [-+]* ) ]]; then
+ comparguments -M match
- comparguments -M match
+ if comparguments -s single; then
- if comparguments -s single; then
+ _description expl option
- _description expl option
+ if [[ "$single" = direct ]]; then
+ compadd "$expl[@]" -QS '' - "${PREFIX}${SUFFIX}"
+ elif [[ "$single" = next ]]; then
+ compadd "$expl[@]" -Q - "${PREFIX}${SUFFIX}"
+ elif [[ "$single" = equal ]]; then
+ compadd "$expl[@]" -QqS= - "${PREFIX}${SUFFIX}"
+ else
+ tmp1=( "$next[@]" "$direct[@]" "$odirect[@]" "$equal[@]" )
+ tmp1=( "${(M@)tmp1:#[-+]?(|:*)}" )
+ tmp2=( "${PREFIX}${(@M)^${(@)${(@)tmp1%%:*}#[-+]}:#?}" )
- if [[ "$single" = direct ]]; then
- compadd "$expl[@]" -QS '' - "${PREFIX}${SUFFIX}"
- elif [[ "$single" = next ]]; then
- compadd "$expl[@]" -Q - "${PREFIX}${SUFFIX}"
- elif [[ "$single" = equal ]]; then
- compadd "$expl[@]" -QqS= - "${PREFIX}${SUFFIX}"
+ _describe -o -c "$cmd" -f "$funcstack[2]" option \
+ tmp1 tmp2 -Q -S ''
+ fi
+ single=yes
else
- tmp1=( "$next[@]" "$direct[@]" "$odirect[@]" "$equal[@]" )
- tmp1=( "${(M@)tmp1:#[-+]?(|:*)}" )
- tmp2=( "${PREFIX}${(@M)^${(@)${(@)tmp1%%:*}#[-+]}:#?}" )
-
- _describe -o -c "$cmd" option tmp1 tmp2 -Q -S ''
+ next=( "$next[@]" "$odirect[@]" )
+ _describe -o -c "$cmd" -f "$funcstack[2]" option \
+ next -Q -M "$match" -- \
+ direct -QS '' -M "$match" -- \
+ equal -QqS= -M "$match"
fi
- single=yes
- else
- next=( "$next[@]" "$odirect[@]" )
- _describe -o -c "$cmd" option \
- next -Q -M "$match" -- \
- direct -QS '' -M "$match" -- \
- equal -QqS= -M "$match"
fi
-
- if [[ nm -eq compstate[nmatches] && -z "$aret" &&
- ( ( -z "$single" && "$PREFIX" = [-+]*\=* ) ||
- "$PREFIX" = --* ) ]]; then
+ if [[ -n "$opts" && -z "$aret$matched" && nm -ne compstate[nmatches] &&
+ "$tags" = *:argument* ]]; then
local prefix suffix
- prefix="${PREFIX#*\=}"
- suffix="$SUFFIX"
- PREFIX="${PREFIX%%\=*}"
- SUFFIX=''
- compadd -M "$match" -D equal - "${(@)equal%%:*}"
+ prefix="${PREFIX#*\=}"
+ suffix="$SUFFIX"
+ PREFIX="${PREFIX%%\=*}"
+ SUFFIX=''
+ compadd -M "$match" -D equal - "${(@)equal%%:*}"
if [[ $#equal -eq 1 ]]; then
PREFIX="$prefix"
@@ -277,11 +282,13 @@ if comparguments -i "$compconfig[autodescribe_options]" "$@"; then
IPREFIX="${IPREFIX}${equal[1]%%:*}="
matched=yes
comparguments -L "$equal[1]" descr action
+ tags=argument
continue
- fi
+ fi
fi
- fi
- break
+ break
+ done
+ [[ -n "$aret" || nm -ne compstate[nmatches] ]] && break
done
[[ -n "$aret" ]] && return 300
@@ -292,7 +299,6 @@ if comparguments -i "$compconfig[autodescribe_options]" "$@"; then
# Set the return value.
[[ nm -ne "$compstate[nmatches]" ]]
-
else
return 1
fi