From: Andrey Borzenkov <arvidjaar@gmail.com>
To: Danek Duvall <duvall@comfychair.org>, zsh-workers@sunsite.dk
Subject: Re: completion based on context earlier in the line
Date: Wed, 11 Feb 2009 21:39:50 +0300 [thread overview]
Message-ID: <200902112139.52429.arvidjaar@gmail.com> (raw)
In-Reply-To: <20090211182808.GA20929@lorien.comfychair.org>
[-- Attachment #1: Type: text/plain, Size: 2072 bytes --]
On 11 of February 2009 21:28:08 Danek Duvall wrote:
> I'm having trouble figuring out how to do this. I've got a command,
> "svccfg", which can look roughly like:
>
> svccfg -s <service> describe <property>
>
> I'm trying to figure out how to complete <property>, but it has to be
> based on <service>, and I've no idea how to get the value of
> <service> to the property completion function.
>
> My _svccfg looks roughly like this (the full thing is in the zsh
> distro):
>
> if [[ $service == "svccfg" ]]; then
> _arguments -s \
> '-s[FMRI on which to operate]:fmri:_svcs_fmri -c' \
> <other options> \
> '*::command:->subcmd' && return 0
>
> if (( CURRENT == 1 )); then
> _wanted <subcommand completion>
> return
> fi
>
> service="$words[1]"
> curcontext=...
> fi
>
> case $service in
> (describe)
> _arguments -A "-*" \
> ":property:_smf_properties"
>
> So I want to extract the argument to -s (if it exists) and pass it to
> _smf_properties down below. But I don't know how.
You probably could use opt_args array:
In addition to $state, _arguments also sets the global
parameters `context', `line' and `opt_args' as described
below, and does not reset any changes made to the special
parameters such as PREFIX and words. This gives the calling
function the choice of resetting these parameters or
propagating changes in them.
During the performance of the action the array `line' will be set
to the command name and normal arguments from the command line,
i.e. the words from the command line excluding all options and
their arguments. Options are stored in the associative array
`opt_args' with option names as keys and their arguments as the
values. For options that have more than one argument these are
given as one string, separated by colons. All colons in the
original arguments are preceded with backslashes.
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2009-02-11 18:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-11 18:28 Danek Duvall
2009-02-11 18:39 ` Andrey Borzenkov [this message]
2009-02-11 19:10 ` [] " Danek Duvall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200902112139.52429.arvidjaar@gmail.com \
--to=arvidjaar@gmail.com \
--cc=duvall@comfychair.org \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).