Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: New options & arguments processing system for ZSH
- X-seq: zsh-workers 15671
- From: Felix Rosencrantz <f_rosencrantz@xxxxxxxxx>
- To: martin.ebourne@xxxxxxxxxxxx, zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: New options & arguments processing system for ZSH
- Date: Tue, 21 Aug 2001 06:50:10 -0700 (PDT)
- In-reply-to: <OF37045DDA.B648BDA3-ON80256AAE.003870CD@xxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
I'll try to be a little more descriptive. When completing, like so:
prompt% yes -<TAB>
---- option
--lines --sleep -l -s -- positive integer number
--escape --no-escape -E -h
--help --no-newline -e -n
There is no help on what the options do. There's nothing that says -l means
"Output only count times". Actually, there is sort of a problem with the
listing, since it says that the --lines,-l,-s,--sleep options are the same
because of the new "equivalence matching".
I created a new version of yes, called yes2, which I've attached. It behaves
more like what I would like to see during completion, as such:
prompt% yes2 -<TAB>
---- option
--escape -e -- __Interpret escape characters as for echo (default unless
--help -h -- __Provide help
--lines -l -- __Output only count times
--no-escape -E -- __Prevent interpretation of escape characters
--no-newline -n -- __Suppress output of automatic newline
--sleep -s -- __Pause for number of seconds between each echo
But notice the duplication of the option explanation via the '* help="..."'
syntax. (I added the double underscores, just to make sure that is where the
text was coming from.)
The way I read your mail, though, is that the yes2 output should be coming
from the original "yes" script. So there might be a problem somewhere,
or I just didn't understand you.
>Since _arguments doesn't decode values for use I don't see how that would
>work.
If you use a state action, _arguments puts information in the opt_args
associative array. I think it could be useful if there was a little
more control how parsed values are stored like provided by parse_opts.
-FR.
----------BEGIN yes2
local -A opts
parse_opts - opts -- "$argv[@]" <<'EOF' || return 1
Description:
Repeatedly print a string
Usage:
yes2 [options] [<text> ...]
Options:
-e, --escape Interpret escape characters as for echo (default
unless
the BSD_ECHO option is set)
# [echoopt] += --escape | -e : constant=-e *
help="__Interpret escape characters as for echo (default unless the BSD_ECHO
option is set)"
-E, --no-escape Prevent interpretation of escape characters
# [echoopt] += --no-escape | -E : constant=-E *
help="__Prevent interpretation of escape characters"
-h, --help Provide this help
# --help | -h * help="__Provide help"
-l <count>, --lines=<count> Output only count times
# --lines | -l : posinteger * help="__Output only count
times"
-n, --no-newline Suppress output of automatic newline
# [echoopt] += --no-newline | -n : constant=-n *
help="__Suppress output of automatic newline"
-s <seconds>, --sleep=<seconds>
Pause for number of seconds between each echo
# --sleep | -s : posinteger * help="__Pause for number of
seconds between each echo"
Arguments:
[<text> ...] Optional text to print. Defaults to 'yes'
# [text] += [*] text
EOF
# Output as required
while (( ${opts[lines]:-1} ))
do
echo $=opts[echoopt] ${opts[text]:-yes}
(( opts[sleep] )) && sleep $opts[sleep]
(( opts[lines] && opts[lines]-- ))
done
----------END yes2
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author