zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-users@sunsite.dk
Subject: Re: completing a single clearcase command
Date: Mon, 10 Feb 2003 11:50:56 +0000	[thread overview]
Message-ID: <24703.1044877856@csr.com> (raw)
In-Reply-To: "Eric.D.Friedman@WellsFargo.COM"'s message of "Fri, 07 Feb 2003 13:32:56 PST." <8F6C90BF40FFD211948B0001FA7E51661288DF8F@xcem-casfo-13.wellsfargo.com>

Eric.D.Friedman@WellsFargo.COM wrote:
> The subcommand I'm interested in getting completion on is "setview," which
> has the following usage:
> 
> Usage: setview [-login] [-exec command-invocation] view-tag
> 
> The view-tag argument will be a name pulled from the list of available
> views.  A list of these can be gotten (1 entry per line) by running
> "cleartool lsview -short"

Exactly this sort of thing is done by the _p4 script I submitted to the
archive (it's in 4.1.0-dev-7).  I suspect bits of Perforce were inspired
by ClearCase.  In particular, _p4_clients extracts a list of `clients',
which are sort of a bit like a view (only not so flexible).

> But, I'd like to still be able to get file completion and so forth on other
> clearcase subcommands, so it's important that that not be disabled in the
> process.

The following should do exactly what you want --- and no more, but it
should be obvious where to put extra handling.  It's not in the most
extensible form, but it is in about the most transparent.

As look would have it, we have ClearCase here for a month's evaluation,
so I was able to test this.  It's obviously not the best start for a
completely general completion.

(Purists might object to my use of `_describe', but it's a nice easy way
of injecting a description and a tag if you can't remember the syntax
for compadd :-/)


#compdef cleartool

local -a array
if (( CURRENT == 2 )); then
  # We are completing the subcommand word; no point
  # in doing files here.  A simple way of adding a list is
  array=($(cleartool help | awk '$1 == "Usage:" { print $2 }'))
  _describe -t subcommands 'cleartool command' array
else
  # We are after the subcommand, so we can examine it.
  # Decide if it's something we want to handle here, or
  # just let default completion take over.
  case $words[2] in
      (setview) array=($(cleartool lsview -short))
		_describe -t views 'ClearCase view' array
		;;
      (*) _default
          return
	  ;;
  esac
fi

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


      parent reply	other threads:[~2003-02-10 11:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-07 21:32 Eric.D.Friedman
2003-02-07 22:24 ` Paul Lew
2003-02-07 22:27   ` Dan Nelson
2003-02-08 19:44 ` Bart Schaefer
2003-02-09 21:38 ` Felix Rosencrantz
2003-02-10 11:50 ` Peter Stephenson [this message]

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=24703.1044877856@csr.com \
    --to=pws@csr.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).