From: Bill Burton <billb@progress.com>
To: Zsh Users List <zsh-users@sunsite.dk>
Subject: Completing on options in name=value format?
Date: Mon, 03 Feb 2003 17:48:31 -0500 [thread overview]
Message-ID: <3E3EF1BF.8040403@progress.com> (raw)
Hello,
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.
2. The .pf suffix for the filename on the pf option isn't stripped off.
3. After completing an option and its argument, there's an extranious
"=" appended to the end:
startws area=intra=
Upon entering a space, it's removed but it shouldn't be
there to begin with.
This is the function so far:
#compdef startws servedb shutdb
local curcontext="$curcontext" state line expl area_dirs
typeset -A val_args
case "$service" in
startws|servedb|shutdb)
_values -C -s = "Options" \
'area[area directory]:area:->areas' \
'pf[parameter file]:parameter file:->pf' \
'test[test or trace mode]::test:(yes no)' \
&& return 0
;;
esac
[[ -n "$state" ]] &&
case "$state" in
areas)
# directories contain a conf/ subdir one or two levels down
area_dirs=( ${BASEDIR:-/usr/local}/*/conf
${BASEDIR:-/usr/local}/*/*/conf )
# TODO: filter out certain directories
# lop off the prefix, i.e. /usr/local/ and /conf suffix
area_dirs=( ${${area_dirs#${BASEDIR:-/usr/local/}}%/conf} )
compadd -qS = -a area_dirs
;;
pf)
local area
for w in $words; do
case "$w" in
area=*)
area=${w#area=}
break;
;;
esac
done
# BUG: -s .pf doesn't strip off the .pf suffix
[[ -n $area ]] && compadd -f -W ${BASEDIR:-/usr/local}/${area}/conf/
-g \*.pf -s .pf
;;
esac
return 1
Thanks for any assistance,
-Bill
next reply other threads:[~2003-02-03 22:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-03 22:48 Bill Burton [this message]
2003-02-11 8:11 ` Oliver Kiddle
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=3E3EF1BF.8040403@progress.com \
--to=billb@progress.com \
--cc=zsh-users@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).