zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.dk
Subject: Re: completion function for apachectl
Date: Mon, 26 Feb 2001 11:13:19 +0100 (MET)	[thread overview]
Message-ID: <200102261013.LAA28626@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Fletch's message of 23 Feb 2001 10:07:14 -0500


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


             reply	other threads:[~2001-02-26 10:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-26 10:13 Sven Wischnowsky [this message]
2001-02-26 14:31 ` Fletch
  -- strict thread matches above, loose matches on Subject: below --
2001-02-23 15:07 Fletch

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=200102261013.LAA28626@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@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).