Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Completion: make certain options' arguments complete according to arguments given to previous options
- X-seq: zsh-workers 42819
- From: Doron Behar <doron.behar@xxxxxxxxx>
- To: Jun T <takimoto-j@xxxxxxxxxxxxxxxxx>
- Subject: Re: Completion: make certain options' arguments complete according to arguments given to previous options
- Date: Fri, 25 May 2018 22:46:48 +0300
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Q4G+2Kv343uwLEb2oIb1RPrQthW5i3Dmds++GUzHRzY=; b=WiFzPazPXiye53n/IqcCMXJ01Q7ItnGuAl4r8lt+XQELIfAZLUBSnzKpRstdQ2WGF9 ruaJPU38xk4ORtzMDLA0scyBUeqvr4x0K/tXTj4ni97OiQUexz6daQrVG587Tej1YT8R iEBN5BtQDpAROn3TeKe4kmSoDh8rYgRO/OngEocc3xVCciVqTbHk9MwYIZVfqaqQj+Q3 VpvCFFLfokVH6m7m+OnOVvL0kLlq9LkjYWCh0GEO6J2Lapata7gWh4XETnOR2ICErLc6 MH8GELuPsAQROEkzCdC5oAmdLw4gh+2t+0/5JpuJ1pc4Bvco5V98JtoMRhoilmcT0oLg kneQ==
- In-reply-to: <F109C9FF-0179-4137-9DC2-045E98052BFE@kba.biglobe.ne.jp>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mail-followup-to: Jun T <takimoto-j@xxxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20180523193027.yfbx5v77roaoy42n@NUC.doronbehar.com> <F109C9FF-0179-4137-9DC2-045E98052BFE@kba.biglobe.ne.jp>
Cool!
Is there a way to know if a certain argument was given? I'm talking
about the case where this argument doesn't accept an argument.
On Thu, May 24, 2018 at 10:57:23AM +0900, Jun T wrote:
>
> > 2018/05/24 4:30, Doron Behar <doron.behar@xxxxxxxxx> wrote:
> >
> > If the `--datadir=` option is used, `cmd` knows that templates should be
> > looked for in the specified directory only. If `--datadir` isn't
> > specified, there is a default data directory `cmd` looks for templates
> > in it.
>
> You can use the associative array 'opt_args' to find the options and their
> args on the command line so far:
>
>
> #compdef cmd
> local curcontext="$curcontext" state state_descr line ret=1
> typeset -A opt_args
>
> _arguments -C : \
> '--datadir=[specify data directory]:data directory:_files -/' \
> '--template=[specify template file]:template file:->template' && ret=0
>
> case $state in
> template)
> local data_dir=$opt_args[--datadir]
> [[ -z $data_dir ]] && data_dir=/etc # default data directory
> _files -W data_dir && ret=0
> ;;
> esac
>
> return ret
>
>
>
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author