diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-11-15 12:01:46 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-11-15 12:01:46 +0000 |
commit | 35b2633ad941966f5fca07b625a594a5b68c0fdb (patch) | |
tree | b54740d014e594ba5d81931cdcdb3387bcf9dfca /Completion/Base/_arguments | |
parent | bb98460a01ce1f6c1e71f7e401f782c81b71486b (diff) | |
download | zsh-35b2633ad941966f5fca07b625a594a5b68c0fdb.tar.gz zsh-35b2633ad941966f5fca07b625a594a5b68c0fdb.tar.xz zsh-35b2633ad941966f5fca07b625a594a5b68c0fdb.zip |
manual/8639
Diffstat (limited to 'Completion/Base/_arguments')
-rw-r--r-- | Completion/Base/_arguments | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/Completion/Base/_arguments b/Completion/Base/_arguments index fbc7d7875..531b11407 100644 --- a/Completion/Base/_arguments +++ b/Completion/Base/_arguments @@ -3,7 +3,8 @@ # Complete the arguments of the current command according to the # descriptions given as arguments to this function. -local long cmd="$words[1]" descr mesg subopts +local long cmd="$words[1]" descr mesg subopts opt usecc autod +local oldcontext="$curcontext" long=$argv[(I)--] if (( long )); then @@ -151,30 +152,33 @@ if (( long )); then set -- "$tmpargv[@]" "${(@P)name}" fi -if [[ "$1" = -O?* ]]; then - subopts=( "${(@P)1[3,-1]}" ) - shift -elif [[ "$1" = -O ]]; then - subopts=( "${(@P)1}" ) - shift 2 -else - subopts=() -fi +subopts=() +while getopts ':O:C' opt; do + if [[ "$opt" = O ]]; then + subopts=( "${(@P)OPTARG}" ) + else + usecc=yes + fi +done -if comparguments -i "$compconfig[autodescribe_options]" "$@"; then +shift OPTIND-1 + +_style -s options auto-description autod + +if comparguments -i "$autod" "$@"; then local nm="$compstate[nmatches]" action noargs aret expl local local next direct odirect equal single match matched ws tmp1 tmp2 - local opts _sub_context oldsc="${_sub_context}" + local opts subc if comparguments -D descr action; then - comparguments -C _sub_context - _sub_context="${oldsc}:${oldsc:+${oldsc}-}${_sub_context}" + comparguments -C subc + curcontext="${oldcontext}:$subc" if comparguments -O next direct odirect equal; then opts=yes - _tags "${oldsc}:any" arguments options + _tags arguments options else - _tags "${oldsc}:any" arguments + _tags arguments fi else if comparguments -a; then @@ -185,7 +189,7 @@ if comparguments -i "$compconfig[autodescribe_options]" "$@"; then comparguments -O next direct odirect equal || return 1 opts=yes - _tags "${oldsc}:any" options + _tags options fi while _tags; do @@ -196,6 +200,11 @@ if comparguments -i "$compconfig[autodescribe_options]" "$@"; then if [[ "$action" = -\>* ]]; then comparguments -W line opt_args state="${${action[3,-1]##[ ]#}%%[ ]#}" + if [[ -n "$usecc" ]]; then + curcontext="$subc" + else + context="$subc" + fi compstate[restore]='' aret=yes else @@ -248,7 +257,7 @@ if comparguments -i "$compconfig[autodescribe_options]" "$@"; then fi fi if [[ -z "$matched" ]] && _requested options && - { ! _style options prefix-needed yes || + { ! _style options prefix-needed || [[ "$PREFIX" = [-+]* ]] } ; then comparguments -M match @@ -296,8 +305,8 @@ if comparguments -i "$compconfig[autodescribe_options]" "$@"; then SUFFIX="$suffix" IPREFIX="${IPREFIX}${equal[1]%%:*}=" matched=yes - comparguments -L "$equal[1]" descr action _sub_context - _sub_context="${oldsc}:${oldsc+${oldsc}-}${_sub_context}" + comparguments -L "$equal[1]" descr action subc + curcontext="${oldcontext}:$subc" continue fi fi @@ -306,6 +315,8 @@ if comparguments -i "$compconfig[autodescribe_options]" "$@"; then [[ -n "$aret" || nm -ne compstate[nmatches] ]] && break done + [[ -z "$aret" || -z "$usecc" ]] && curcontext="$oldcontext" + [[ -n "$aret" ]] && return 300 [[ -n "$mesg" ]] && _message "$mesg" |