Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Completing on options in name=value format?

On 3 Feb, Bill Burton wrote:
> I'm writing a completion function for some home grown scripts that 
> require options in the format name=value.  I'm having two problems with 
> my function:
> The command is as follows with the area and pf options required but the 
> test option is not:
>    startws area=<a subdirecties under /usr/local> \
>            pf=<a file with a .pf suffix relative to
>               the directory completed in the area option>
>            test={yes|no}
> In order to complete the pf option, the area option must be specified first.
> The function mostly works but I still have the following issues:
> 1. After I complete on the area= option, it still shows up on the 
> completion menu.

In zsh 4.1 there is a -w option to _values that will fix this. _values
isn't as good as I'd like. The issues were discussed in depth in
relation to _dd if you want to search the archives for it.
> 2. The .pf suffix for the filename on the pf option isn't stripped off.

I think you've misunderstood what -s to compadd does. -W and -g are
options to _files and not compadd.

How you should write it depends on whether you want to complete
subdirectories along with .pf files. If not,
  compadd ${BASEDIR:-/usr/local}/${area}/conf/*.pf(:r:t)
should do it.

> 3. After completing an option and its argument, there's an extranious 
> "=" appended to the end:

That's what you told it to do in the line:
   compadd -qS = -a area_dirs

At least in 4.1, your -s = argument to _values is redundant. -S specifies
the separator between values and their arguments (default =) while -s
specifies the value separator.


This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.

Messages sorted by: Reverse Date, Date, Thread, Author