* RE: completing a single clearcase command
2003-02-07 21:32 completing a single clearcase command Eric.D.Friedman
@ 2003-02-07 22:24 ` Paul Lew
2003-02-07 22:27 ` Dan Nelson
2003-02-08 19:44 ` Bart Schaefer
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Paul Lew @ 2003-02-07 22:24 UTC (permalink / raw)
To: Eric.D.Friedman; +Cc: zsh-users
>>>>> "Eric" == Eric D Friedman <Eric.D.Friedman@WellsFargo.COM> writes:
Eric> <snip>
Eric> The subcommand I'm interested in getting completion on is
Eric> "setview," which has the following usage:
Eric> Usage: setview [-login] [-exec command-invocation] view-tag
I have been using a clearcase completion that is capable of the above.
But it is written in compctl. Drop me a mail if you like and I will
mail you a copy. I am interested in repalcement with the 'new'
completion system too.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: completing a single clearcase command
2003-02-07 22:24 ` Paul Lew
@ 2003-02-07 22:27 ` Dan Nelson
0 siblings, 0 replies; 6+ messages in thread
From: Dan Nelson @ 2003-02-07 22:27 UTC (permalink / raw)
To: Paul Lew; +Cc: Eric.D.Friedman, zsh-users
In the last episode (Feb 07), Paul Lew said:
> >>>>> "Eric" == Eric D Friedman <Eric.D.Friedman@WellsFargo.COM> writes:
>
> Eric> <snip>
> Eric> The subcommand I'm interested in getting completion on is
> Eric> "setview," which has the following usage:
>
> Eric> Usage: setview [-login] [-exec command-invocation] view-tag
>
> I have been using a clearcase completion that is capable of the above.
> But it is written in compctl. Drop me a mail if you like and I will
> mail you a copy. I am interested in repalcement with the 'new'
> completion system too.
_cvs might be a useful template; it also has subcommands with their own
arguments and flags.
--
Dan Nelson
dnelson@allantgroup.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: completing a single clearcase command
2003-02-07 21:32 completing a single clearcase command Eric.D.Friedman
2003-02-07 22:24 ` Paul Lew
@ 2003-02-08 19:44 ` Bart Schaefer
2003-02-09 21:38 ` Felix Rosencrantz
2003-02-10 11:50 ` Peter Stephenson
3 siblings, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2003-02-08 19:44 UTC (permalink / raw)
To: zsh-users
On Feb 7, 1:32pm, Eric.D.Friedman@WellsFargo.COM wrote:
}
} Like CVS, clearcase has a 2-level command system. The first command is
} always "cleartool" (usually aliased to "ct"). The second is the real
} operation you want to do. So, for example, "ct ls" does a cleartool
} equivalent of ls.
The most thorough examples of completion for this sort of command are
Completion/Unix/Command/_cvs and Completion/Debian/Command/_apt. The
former uses _arguments to parse the command line, and the latter uses
_regex_arguments which allows more detailed pattern-matching but has a
somewhat more tangled syntax.
Which one is better depends on how complex the stuff between "ct" and
the operation name may be. If there are never any arguments to "ct"
before the operation name, look at Completion/Debian/Command/_bts.
A less intense _regex_arguments example is Completion/X/Command/_xset.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: completing a single clearcase command
2003-02-07 21:32 completing a single clearcase command Eric.D.Friedman
2003-02-07 22:24 ` Paul Lew
2003-02-08 19:44 ` Bart Schaefer
@ 2003-02-09 21:38 ` Felix Rosencrantz
2003-02-10 11:50 ` Peter Stephenson
3 siblings, 0 replies; 6+ messages in thread
From: Felix Rosencrantz @ 2003-02-09 21:38 UTC (permalink / raw)
To: Eric.D.Friedman, zsh-users
If you just want something to work, I suggest using Gorgan Koruga's clearcase
completion function as a base, which can be found at:
http://www.zsh.org/mla/users/2001/msg00649.html
It handles a small set of the cleartools commands, but I suspect a good
used subset.
As part of my attempts to automatically create completion functions, I decided
to tackle cleartool, generating a completion function via the help output. I
wanted to automate the process, in order to make it easy to keep up with new
versions. For details:
http://www.geocities.com/f_rosencrantz/clearcase_generation.htm
Based on what you said, it sounds like you might have found the one I
generated, and it wasn't very helpful. Mine has several problems. One
significant problem when you attempt to use it, is that it is missing a
_cc_views function, and other functions that return lists of items (e.g. branch
names, type names,...) You could write your own or steal them from Gorgan's
function.
His function also has examples of creating these "listing functions".
Basically, a listing function is something that runs some command (ct lsview
-short), which generates of list of possible values you want to complete. You
have to parse the command output, find the values you want, and return those in
the proper format.
If there is demand, I would be willing to add my clearcase completion function
to the codeline. It is pretty big, about the same size as the larch completion
function, which seems to be the largest one right now.
Once it is in the codeline, it would be easier for other folks to contribute
changes and make it more useful. I haven't had access to Clearcase for a
while, so it is difficult to get listing functions that work.
-FR.
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: completing a single clearcase command
2003-02-07 21:32 completing a single clearcase command Eric.D.Friedman
` (2 preceding siblings ...)
2003-02-09 21:38 ` Felix Rosencrantz
@ 2003-02-10 11:50 ` Peter Stephenson
3 siblings, 0 replies; 6+ messages in thread
From: Peter Stephenson @ 2003-02-10 11:50 UTC (permalink / raw)
To: zsh-users
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.
**********************************************************************
^ permalink raw reply [flat|nested] 6+ messages in thread