[p4] Bash completion with depot paths
Andrew May
acmay at acmay.homeip.net
Thu Oct 4 10:29:10 PDT 2007
On Thu, 20 Sep 2007 16:03:36 -0700
"John Hopkins" <johnh at ca.sophos.com> wrote:
> > Date: Wed, 19 Sep 2007 08:49:16 -0700
> > From: Andrew May <acmay at acmay.homeip.net>
> > Subject: [p4] Bash completion with depot paths
> > To: Perforce Users <perforce-user at perforce.com>
> >
> > I have been working on getting tab completions working for depot
> > paths with the bash completion file started by Frank Cusak. It took
> > a bit of flailing to get the dirs/files to expand ok without
> > putting in the extra spaces that would throw things off along the
> > way. That seemed to be the problem another person ran into on this
> > mailing list too.
>
> I've seen UNIX developers create a directory (or symlink) under the
> root of their directory hierarchy which gives them depot path
> completion for free. Your client spec would be rooted at /depot if
Our depot is way too big for that to work. While the file complete is
nice, the context sensitive completes is where the functions really can
out do any type of symlink trick that people come up with.
I have been a bit sidetracked, and it is very tedious work going
through all the different commands and options to get things right.
Have things like "p4 client -t <tab>" pull up a list of clients for a
template is very nice. But then when you do "p4 add -t <tab>" it needs
to know that it is now a filetype instead of client. But other commands
use -t without any args at all.
And then having "p4 diff2 -b <tab>" pull up the branches is very nice
to have.
So far I have come up with -t/-c/-b/-u/-s, and they should work ok. I
have only made it through the "i" commands, so there may be more
conflicting uses of them for different commands.
"-t" seems to be the most re-defined arg so far, and the basic
structure I have to handle it is like this:
==============================================================
#Try to handle all the flags that need to take arguments.
#it may depend on the command on what the flag actually does.
# ie -b is always with a branch?
# but -t can be a filetype, or template clientspec, or timestamp flag
# depending on the command
if [ "${prev:0:1}" = "-" ]; then
case "$prev" in
-t)
case "$cmd" in
add|edit|reopen)
COMPREPLY=( $( compgen -W "$p4filetypes" \
-- $cur) )
return 0
;;
client|workspace)
_p4_spec_complete clients $cur
return 0
;;
changes|filelog)
#nothing to do just date
;;
*)
;;
esac
;;
-c)
.....
More information about the perforce-user
mailing list