* Re: completion function for apachectl
@ 2001-02-26 10:13 Sven Wischnowsky
2001-02-26 14:31 ` Fletch
0 siblings, 1 reply; 3+ messages in thread
From: Sven Wischnowsky @ 2001-02-26 10:13 UTC (permalink / raw)
To: zsh-workers
Fletch wrote:
> This completes for apachectl (a utility that comes with apache
> to do things such as restarting apache, syntax checking it's
> configuration file, and the like).
Thanks for writing a new completion function.
Just some comments:
> +#compdef apachectl
> +
> +local curcontext="$curcontext" state line commands ret=1
> +typeset -A opt_args
Most of these need only be made local if `_arguments' is used with a
`->state' action.
> +commands=( start startssl stop restart fullstatus status
> + graceful configtest help )
Using an extra array maybe slightly more readable, but in a function
as simple as this one...
> +_arguments \
> + ":Choose an action:($commands)" && ret=0
> +
> +return $ret
No need for `&& ret=0 ... return $ret'. Without a `return' the return
value of a function is the return value of the last command in it.
And using `_arguments' is only really useful if there is some more to
do (options, multiple arguments,...) -- otherwise it's quite
expensive.
One could get the same with the simpler:
#compdef apachectl
local expl
if [[ CURRENT -eq 2 ]]; then
_wanted commands expl command compadd \
start startssl stop restart fullstatus status graceful configtest help
else
_message 'no more arguments'
fi
Hm. Since there are several commands (and scripts[1]) that only get one
command as argument, I'm almost tempted to add a generic version of
the above as a utility function. Opinions?
Bye
Sven
[1] Wasn't there a request for init-script completion on the debian list?
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: completion function for apachectl
2001-02-26 10:13 completion function for apachectl Sven Wischnowsky
@ 2001-02-26 14:31 ` Fletch
0 siblings, 0 replies; 3+ messages in thread
From: Fletch @ 2001-02-26 14:31 UTC (permalink / raw)
To: Sven Wischnowsky; +Cc: zsh-workers
>>>>> "Sven" == Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:
Sven> Fletch wrote:
>> This completes for apachectl (a utility that comes with apache
>> to do things such as restarting apache, syntax checking it's
>> configuration file, and the like).
Sven> Thanks for writing a new completion function.
[... Brutal savaging of my version choped :) ]
Thanks for critiquing it. It was rather cargo cultish and
hacked together from the bits and pieces of whatever looked similar to
what I was trying to do. I better go re-read that section of the
guide a couple more times.
Sven> Hm. Since there are several commands (and scripts[1]) that
Sven> only get one command as argument, I'm almost tempted to add
Sven> a generic version of the above as a utility
Sven> function. Opinions?
Sven> Bye Sven
Sven> [1] Wasn't there a request for init-script completion on the
Sven> debian list?
I've been frustrated that TAB doesn't Do What I Mean for stuff
in /etc/rc.d/init.d several times. You almost could generate it on
the fly with a for over /etc/rc.d/init.d/*, maybe with a style for
things that take strange arguments other than start or stop.
--
Fletch | "If you find my answers frightening, __`'/|
fletch@phydeaux.org | Vincent, you should cease askin' \ o.O'
770 933-0600 x211(w) | scary questions." -- Jules =(___)=
| U
^ permalink raw reply [flat|nested] 3+ messages in thread
* completion function for apachectl
@ 2001-02-23 15:07 Fletch
0 siblings, 0 replies; 3+ messages in thread
From: Fletch @ 2001-02-23 15:07 UTC (permalink / raw)
To: zsh-workers
This completes for apachectl (a utility that comes with apache
to do things such as restarting apache, syntax checking it's
configuration file, and the like).
--- /dev/null Tue May 5 16:32:27 1998
+++ _apachectl Fri Feb 23 10:01:49 2001
@@ -0,0 +1,12 @@
+#compdef apachectl
+
+local curcontext="$curcontext" state line commands ret=1
+typeset -A opt_args
+
+commands=( start startssl stop restart fullstatus status
+ graceful configtest help )
+
+_arguments \
+ ":Choose an action:($commands)" && ret=0
+
+return $ret
--
Fletch | "If you find my answers frightening, __`'/|
fletch@phydeaux.org | Vincent, you should cease askin' \ o.O'
770 933-0600 x211(w) | scary questions." -- Jules =(___)=
| U
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-02-26 14:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-26 10:13 completion function for apachectl Sven Wischnowsky
2001-02-26 14:31 ` Fletch
-- strict thread matches above, loose matches on Subject: below --
2001-02-23 15:07 Fletch
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).