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

Re: Completing multiple states with _arguments



On Wed, 10 Nov 2010 12:23:50 +0100
Nikolai Weibull <now@xxxxxxxx> wrote:
> >> local context state line
> >> typeset -A opt_args
> >>
> >> _arguments \
> >> Â ':: :->something-optional-before-files' \
> >> Â '*:: :->file' && ret=0
> >>
> >> # Now what?
> 
> Is it as simple as
> 
> local s
> for s in $state; do
>   case $s in â esac
> done
> 
> or do you need to deal with tags and such through _alternative or so?

I think you do need to set up tags here, at least most scripts do and I
haven't tried without.  However, that should all be standard: looping
over the states is fine, then use the usual _wanted stuff inside the
case and the tags get sorted out automatically, in principle.  There's
nothing to stop you using _alternative, either.

In short, just adding the loop over the state to the sort of stuff that
usually appears in the "case" here should be OK.

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



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