Merge branch 'master' of git+ssh://github.com/adefaria/clearscm
[clearscm.git] / rc / clearcase
1 #!/bin/bash
2 ################################################################################
3 #
4 # File:        $RCSfile: clearcase,v $
5 # Revision:    $Revision: 1.33 $ 
6 # Description: This script set up some useful environment variables and aliases
7 #              for Clearcase execution. File should be sourced (e.g . 
8 #              clearcase)
9 # Author:      Andrew@DeFaria.com
10 # Created:     Wed Jun  5 21:08:03 PDT 1996
11 # Modified:    $Date: 2011/10/24 18:07:05 $
12 # Language:    bash
13 #
14 # (c) Copyright 2000-2016, ClearSCM, Inc., all rights reserved.
15 #
16 ################################################################################
17 if [ $ARCHITECTURE = 'cygwin' ]; then
18   export CCHOME=$(cygpath -u "$(regtool get '/machine/SOFTWARE/Rational Software/RSINSTALLDIR' 2>/dev/null)"/Clearcase 2>/dev/null);
19 else 
20   export CCHOME="/opt/rational/clearcase"
21 fi
22
23 if [ ! -d "$CCHOME" ]; then
24   unset CCHOME
25 #  exit
26 fi
27
28 # Source in clearcase.conf
29 if [ -f ~/.rc/clearcase.conf ]; then
30   source ~/.rc/clearcase.conf
31 else
32   echo "WARNING: Could not find ~/.rc/clearcase.conf - functionality will be limted"
33 fi
34
35 export CLEARTOOL="$CCHOME/bin/cleartool"
36 export CLEARCASE_BLD_HOST_TYPE="unix"
37
38 if [ -f "$CCHOME/etc/utils/creds" ]; then
39   if [ $ARCHITECTURE = 'cygwin' ]; then
40     alias creds=$(cygpath "$CCHOME/etc/utils/creds")
41   else 
42     alias creds="$CCHOME/etc/utils/creds"
43   fi
44 fi
45
46 if [ -x "$CLEARTOOL" ]; then
47   export RGY="$CCHOME/var/atria/rgy"
48   export LOGS="$CCHOME/var/log"
49 fi
50
51 function scm {
52   scmstatus=0
53
54   if [ -x "$CLEARTOOL" ]; then
55     # Cleartool suddenly started appending ^M's (I think as of 7.1)
56     if [ $ARCHITECTURE = 'cygwin' ]; then
57       # Need to set pipefail to pick up the exit code from cleartool
58       # otherwise we get the exit code from tr which is usually 0
59       set -o pipefail
60       "$CLEARTOOL" "$@" | tr -d "\015"
61       scmstatus=$?
62       set +o pipefail
63     else
64       "$CLEARTOOL" "$@"
65       scmstatus=$?
66     fi
67   else
68     scmstatus=1
69   fi
70
71   return $scmstatus
72 } # scm
73
74 function ct {
75   # Setview is special - there is no setview on Windows. But we approximate it
76   # with the function setview
77   if [ "$1" = "setview" ]; then
78         shift
79         setview "$@"
80   else
81     scm "$@"
82   fi
83   
84   return $scmstatus
85 } # ct
86
87 function scmsystem {
88   if [ "$(scm pwv)" != '' ]; then
89     return 1
90   elif [ -f CVS/Root ]; then
91     return 2
92   else
93     return 0
94   fi
95 } # scmsystem
96
97 function ci {
98   if [ $# = 0 ]; then
99     echo "ci: Error: No files specified"
100   else
101     scm ci "$@"
102   fi
103 } # ci
104
105 function co {
106   if [ $# = 0 ]; then
107     echo "co: Error: No files specified"
108   else
109     scm co "$@"
110   fi
111 } # co
112
113 function unco {
114   if [ $# = 0 ]; then
115     echo "unco: Error: No files specified"
116   else
117     scm unco "$@"
118   fi
119 } # unco
120
121 function lslock {
122   scm lslock "$@"
123 } # lslock
124
125 function lllock {
126   scm lslock -long "$@"
127 } # lllock
128
129 # View related functions
130 function setview {
131   if [ $ARCHITECTURE = 'cygwin' ]; then
132         if [[ $1 = -* ]]; then
133           echo "The setview command with options is not supported on Windows"
134           return
135         fi
136          
137     # Save off where we are
138     back=$PWD
139
140     # Start the view
141     scm startview "$@"
142
143     if [ $? != 0 ]; then
144       return $?
145     fi
146
147     # Setup $VOBTAG_PREFIX
148     mount -f -o binary M:/$1 $LINUX_VOBTAG_PREFIX
149
150     # Start a bash shell
151     bash
152
153     # Remove $LINUX_VOBTAG_PREFIX mount (Ignore errors)
154     umount $LINUX_VOBTAG_PREFIX 2> /dev/null
155
156     # Chdir back to were we started
157     cd $back
158   else
159     scm setview "$@"
160   fi
161
162   set_title
163   set_prompt
164 } # setview
165
166 function startview {
167   scm startview "$@"
168
169   mycd /view/$1
170 } # startview
171
172 function endview {
173   scm endview "$@"
174 } # endview
175
176 function killview {
177   scm endview -server "$@"
178 } # killview
179
180 function mkview {
181   scm mkview "$@"
182 } # mkview
183
184 function makeview {
185   if [ $# != 1 ]; then
186     echo "Usage: $FUNCNAME <stream>"
187     return 1
188   fi
189
190   stream=$1
191
192   # Check to see if the view already exists
193   scm lsview -short ${USER}_$stream > /dev/null 2>&1 
194
195   if [ $? = 0 ]; then
196     echo "${USER}_$stream already exists!"
197   else
198     mkview -tag ${USER}_$stream -stream $stream@$pvob -stgloc -auto
199
200     if [ $? != 0 ]; then
201       echo "Couldn't find that stream. Perhaps it's one of these?"
202       let i=${#stream}-4
203       searchFor=${stream:1:$i}
204       scm lsstream -short -invob $pvob | grep $searchFor | $PAGER
205       return 0
206     fi
207   fi
208
209   setview ${USER}_$stream
210 } # makeview
211
212 function rmview {
213   scm rmview "$@"
214 } # rmview
215
216 function lsview {
217   if [ $# = 0 ]; then
218     scm lsview -s | $PAGER
219   elif [ $# = 1 ]; then
220     scm lsview -s | grep "$1"
221   else
222     scm lsview "$@"
223   fi
224 } # lsview
225
226 function myviews {
227   # Well they asked for my "views"...
228   if [ $(whence fortune) ]; then
229     fortune
230     echo
231   fi    
232
233   # List my views and their associated activities
234   for view in $(scm lsview -s 2>&1 | grep $USER); do
235     headline=$(scm lsact -cact -fmt "%[headline]p" -view $view 2> /dev/null)
236    
237     if [ "$headline" = "" ]; then
238       headline="<no activity set>"
239     fi
240
241     echo -e "$view\t$headline"
242   done
243 } # myviews
244
245 function llview {
246   if [ $# = 0 ]; then
247     scm lsview -long | $PAGER
248   else 
249     scm lsview -long "$@"
250   fi
251 } # llview
252
253 function lsviews {
254   if [ $# = 0 ]; then
255     scm lsview -short
256   else 
257     scm lsview -short | grep $1
258   fi
259 } # lsviews
260
261 # Vob related functions
262 function lsvob {
263   if [ $# = 0 ]; then
264     scm lsvob | $PAGER
265   elif [ $# = 1 ]; then
266     scm lsvob | grep "$1"
267   else
268     scm lsvob "$@"
269   fi
270 } # lsvob
271
272 function llvob {
273   if [ $# = 0 ]; then
274     scm lsvob -long | $PAGER
275   else 
276     scm lsvob -long "$@"
277   fi
278 } # llvob
279
280 function lsvobs {
281   if [ $# = 0 ]; then
282     scm lsvob -short
283   else 
284     scm lsvob -short | grep $1
285   fi
286 } # lsvobs
287
288 # Config spec functions
289 function setcs {
290   scm setcs "$@"
291 } # setcs
292
293 function edcs {
294   scm edcs "$@"
295 } # edcs
296
297 function catcs {
298   scm catcs "$@"
299 } # catcs
300
301 function pwv {
302   scm pwv -s "$@"
303 } # pwv
304
305 function rmtag {
306   scm rmtag "$@"
307 } # rmtag
308
309 function mktag {
310   scm mktag "$@"
311 } # mktag
312
313 function describe {
314   scm describe "$@"
315 } # describe
316
317 function desc {
318   scm describe "$@"
319 } # describe
320
321 function oid2name {
322   if [ $# == 2 ]; then
323     oid=$1
324     projvob=$2
325   elif [ $# == 1 ]; then
326     oid=$1
327     projvob=$pvob
328   else
329     echo "Usage: oid2name: <oid> [<pvob>]"
330     
331     return
332   fi
333   
334   scm describe oid:$oid@$projvob 2> /dev/null | head -1
335 } # oid2name
336
337 function name2oid {
338   if [ $# == 3 ]; then
339     type=$1
340     name=$2
341     projvob=$3
342   elif [ $# == 2 ]; then
343     type=$1
344     name=$2
345     projvob=$pvob
346   else
347     echo "Usage: name2oid: <type> <name> [<pvob>]"
348     
349     return
350   fi
351
352   scm dump $type:$name@$projvob 2> /dev/null | grep oid=
353 } # name2oid
354
355 # Action functions
356 function vtree {
357   if [ $# != 1 ]; then
358     echo "vtree: Error: Must specify an element to view its version tree"
359   else
360     if [ $ARCHITECTURE = 'cygwin' ]; then
361       scm lsvtree -g "$@"
362     else
363       xlsvtree "$@"
364     fi
365   fi
366 } # vtree
367
368 function merge {
369   scm merge "$@"
370 } # merge
371
372 function findmerge {
373   scm findmerge "$@"
374 } # findmerge
375
376 function cdiff {
377   scmsystem; scmtype=$?
378
379   if [ $# = 1 ]; then
380     if [ $scmtype = 1 ]; then
381       scm diff -graphical -pred $1
382     elif [ $scmtype = 2 ]; then
383       cvs diff $1
384     fi
385   else
386     if [ $scmtype = 1 ]; then
387       scm diff -graphical "$@"
388     elif [ $scmtype = 2 ]; then
389       cvs diff "$@"
390     fi
391   fi
392 } # cdiff
393
394 function ctdiff {
395   if [ $# = 1 ]; then
396     scm xdiff -vstack -pred $1
397   else
398     scm xdiff -vstack $@
399   fi
400 } # ctdiff
401
402 # Administrative functions
403 function space {
404   scm space "$@"
405 } # space
406
407 function register {
408   scm register "$@"
409 } # register
410
411 function unregister {
412   scm unregister "$@"
413 } # unregister
414
415 # Information functions
416 function hostinfo {
417   scm hostinfo "$@"
418 } # hostinfo
419
420 function lstrig {
421   if [ $# = 2 ]; then
422     trig_name=$1
423     vob=$2
424     scm lstype trtype:$trig_name@$vob
425   else
426     scm lstype -kind trtype "$@" | $PAGER
427   fi
428 } # lstrig
429
430 function lltrig {
431   if [ $# = 1 ]; then
432     scm lstype -long trtype:$1
433   else
434     scm lstype -long -kind trtype "$@"| $PAGER
435   fi
436 } # lltrig
437
438 function lsbr {
439   scm lstype -brtype
440 } # lsbr
441
442 function lslab {
443   scm lstype -lbtype
444 } # lslab
445
446 # UCM oriented functions
447 function lsstream {
448   if [ $# = 0 ]; then
449     # If we are in a view context then try to list the stream for our view
450     if [[ $(pwv) == "** NONE **" ]]; then
451       lsstreams | $PAGER
452     else
453       scm lsstream | $PAGER
454     fi
455   else
456     # Check to see if a pvob was specified
457     if [[ $@ == *@* ]]; then
458       scm lsstream "$@"
459     else
460       scm lsstream -invob $pvob | grep $1 | $PAGER
461     fi
462   fi
463 } # lsstream
464
465 function llstream {
466   if [ $# = 0 ]; then
467     scm lsstream -l | $PAGER
468   else
469     scm lsstream -l "$@"
470   fi
471 } # llstream
472
473 function lsstreams {
474   if [ $# = 0 ]; then
475     scm lsstream -short -invob $pvob
476   else 
477     scm lsstream -short "$@"
478   fi
479 } # lstreams
480
481 function lsregions () {
482   if [ $# -gt 0 ]; then
483         scm lsregion -short | grep ^$1 
484   else
485     scm lsregion -short
486   fi
487 } # lsregions
488
489 function rebase {
490   scm rebase "$@"
491 } # rebase
492
493 function deliver {
494   scm deliver "$@"
495 } # deliver
496
497 function lsbl {
498   scm lsbl "$@"
499 } # lsbl
500
501 function lsll {
502   scm lsbl -lon "$@"
503 } # llbl
504
505 function lsproj {
506   if [ $# = 0 ]; then
507     scm lsproject | $PAGER
508   else
509     scm lsproject "$@"
510   fi
511 } # lsproj
512
513 function llproj {
514   if [ $# = 0 ]; then
515     scm lsproject -l | $PAGER
516   else
517     scm lsproject -l "$@"
518   fi
519 } # llproj
520
521 function lsfolder {
522   scm lsfolder "$@"
523 } # lsfolder
524
525 function llfolder {
526   scm lsfolder -long "$@"
527 } # llfolder
528
529 function lsstgloc {
530   if [ $# = 0 ]; then
531     scm lsstgloc | $PAGER
532   else
533     scm lsstgloc "$@"
534   fi
535 } # lsstgloc
536
537 function llstgloc {
538   if [ $# = 0 ]; then
539     scm lsstgloc -l | $PAGER
540   else
541     scm lsstgloc -l "$@"
542   fi
543 } # llstgloc
544
545 function lsact {
546   if [ $# = 0 ]; then
547     scm lsactivity | $PAGER
548   else
549     scm lsactivity "$@"
550   fi
551 } # lsact
552
553 function llact {
554   if [ $# = 0 ]; then
555     scm lsactivity -l | $PAGER
556   else
557     scm lsactivity -l "$@"
558   fi
559 } # llact
560
561 function setact {
562   if [ $# = 0 ]; then
563     echo "What? Am I suppose to guess?!?"
564     exit 1
565   else
566     scm setactivity "$@"
567   fi
568 } # setact
569
570 function clist {
571   scmsystem; scmtype=$?
572
573   if [ $scmtype = 1 ]; then
574     scm lsco -short -cview -all -me
575   elif [ $scmtype = 2 ]; then
576     cvs -Q status | grep ^File | grep -v Up-to-date
577   fi
578 } # clist
579
580 function ciwork {
581   scm ci -cq $(clist)
582 } # ciwork
583
584 # Bash completion for Clearcase commands. T
585
586 # Add "," to COMP_BREAKWORDS
587 COMP_WORDBREAKS=\ \"\'\>\<\=\;\|\&\(\:\,
588
589 # All Clearcase commands
590 _scm_cmds="\
591 annotate \
592 catcr \
593 catcs \
594 cd \
595 chactivity \
596 chbl \
597 checkin \
598 checkout \
599 checkvob \
600 chevent \
601 chflevel \
602 chfolder \
603 chmaster \
604 chpool \
605 chproject \
606 chstream \
607 chtype \
608 chview \
609 ci \
610 co \
611 cptype \
612 deliver \
613 describe \
614 diff \
615 diffbl \
616 diffcr \
617 dospace \
618 edcs \
619 endview \
620 file \
621 find \
622 findmerge \
623 get \
624 getcache \
625 getlog \
626 help \
627 hostinfo \
628 ln \
629 lock \
630 ls \
631 lsactivity \
632 lsbl \
633 lscheckout \
634 lscheckout \
635 lsclients \
636 lscomp \
637 lsdo \
638 lsfolder \
639 lshistory \
640 lslock \
641 lsmaster \
642 lspool \
643 lsprivate \
644 lsproject \
645 lsregion \
646 lsreplica \
647 lssite \
648 lsstgloc \
649 lsstream \
650 lstype \
651 lstype \
652 lsview \
653 lsvob \
654 lsvtree \
655 man \
656 merge \
657 mkactivity \
658 mkattr \
659 mkattype \
660 mkbl \
661 mkbranch \
662 mkbrtype \
663 mkcomp \
664 mkdir \
665 mkelem \
666 mkeltype \
667 mkfolder \
668 mkhlink \
669 mkhltype \
670 mklabel \
671 mklbtype \
672 mkpool \
673 mkproject \
674 mkregion \
675 mkstgloc \
676 mkstream \
677 mktag \
678 mktrigger \
679 mktrtype \
680 mkview \
681 mkvob \
682 mount \
683 move \
684 protect \
685 protectvob \
686 pwd \
687 pwv \
688 quit \
689 rebase \
690 recoverview \
691 reformatview \
692 reformatvob \
693 register \
694 relocate \
695 rename \
696 reqmaster \
697 reserve \
698 rmactivity \
699 rmattr \
700 rmbl \
701 rmbranch \
702 rmcomp \
703 rmdo \
704 rmelem \
705 rmfolder \
706 rmhlink \
707 rmlabel \
708 rmmerge \
709 rmname \
710 rmpool \
711 rmproject \
712 rmregion \
713 rmstgloc \
714 rmstream \
715 rmtag \
716 rmtrigger \
717 rmtype \
718 rmver \
719 rmview \
720 rmvob \
721 schedule \
722 setactivity \
723 setcache \
724 setcs \
725 setplevel \
726 setsite \
727 setview \
728 space \
729 startview \
730 umount \
731 uncheckout \
732 unlock \
733 unregister \
734 unreserve \
735 update \
736 winkin \
737 "
738 # Kinds
739 _kinds="\
740 attype \
741 brtype \
742 eltype \
743 hltype \
744 lbtype \
745 trtype \
746 "
747 # Type selectors
748 _type_selectors="\
749 attype: \
750 brtype: \
751 eltype: \
752 hltype: \
753 lbtype: \
754 trtype: \
755 "
756 # These options are common to all scm commands. So far -help is the only one
757 _global_opts="\
758 -help \
759 "
760 # Comment opts. These options are common for commands that request the user
761 # specify a comment
762 _comment_opts="\
763 -c \
764 -cfile \
765 -cq \
766 -cqe \
767 -nc \
768 "
769 # Individual command options
770 _annotate_opts="\
771 $_global_opts \
772 -all \
773 -fmt \
774 -force \
775 -long \
776 -nco \
777 -ndata \
778 -nheader \
779 -out \
780 -rm \
781 -rmfmt \
782 -short \
783 "
784 _catcr_opts="\
785 $_global_opts \
786 -check \
787 -ci \
788 -critical \
789 -element \
790 -flat \
791 -follow \
792 -long \
793 -makefile \
794 -name \
795 -nxname \
796 -recurse \
797 -scripts \
798 -select \
799 -short \
800 -type \
801 -union \
802 -view \
803 -wd \
804 -zero \
805 "
806 _chbl_opts="\
807 $_global_opts \
808 $_comment_opts \
809 -full \
810 -incremental \
811 -level \
812 -nrecurse \
813 "
814 _checkout_opts="\
815 $_global_opts \
816 $_comment_opts \
817 -branch \
818 -ndata \
819 -nmaster \
820 -nquery \
821 -nwarn \
822 -out \
823 -ptime \
824 -query \
825 -reserved \
826 -unreserved \
827 -usehijack \
828 -version \
829 "
830 _chflevel_opts="\
831 $_global_opts \
832 -auto \
833 -family \
834 -force \
835 -master \
836 -override \
837 -replica \
838 "
839 _chpool_opts="\
840 $_global_opts \
841 $_comment_opts \
842 -force \
843 "
844 _chtype_opts="\
845 $_global_opts \
846 $_comment_opts \
847 -force \
848 -pname \
849 "
850 _diff_opts="\
851 $_global_opts \
852 -graphical \
853 -hstack \
854 -options \
855 -predecessor \
856 -serial \
857 -tiny \
858 "
859 _diffbl_opts="\
860 $_global_opts \
861 -activities \
862 -baselines \
863 -first \
864 -graphical \
865 -nmerge \
866 -nrecurse \
867 -predecessor \
868 -versions \
869 "
870 _diffcr_opts="\
871 $_global_opts \
872 -ci \
873 -critical \
874 -element \
875 -follow \
876 -long \
877 -name \
878 -nxname \
879 -recurse \
880 -select \
881 -short \
882 -type \
883 -view \
884 -wd \
885 "
886 _edcs_opts="\
887 $_global_opts \
888 -ctime \
889 -overwrite \
890 -ptime \
891 -rename \
892 -tag \
893 "
894 _deliver_opts="\
895 $_global_opts \
896 -abort \
897 -activities \
898 -baseline \
899 -cact \
900 -cancel \
901 -complete \
902 -force \
903 -gmerge \
904 -graphical \
905 -long \
906 -ok \
907 -preview \
908 -qall \
909 -qntrivial \
910 -query \
911 -reset \
912 -resume \
913 -serial \
914 -short \
915 -status \
916 -stream \
917 -target \
918 -to \
919 "
920 _diff_opts="\
921 $_global_opts \
922 -columns \
923 -diff \
924 -graphical \
925 -hstack \
926 -options \
927 -predecessor \
928 -serial \
929 -tiny \
930 -vstack \
931 "
932 _diffbl_opts="\
933 $_global_opts \
934 -activities \
935 -baselines \
936 -elements \
937 -first \
938 -graphical \
939 -nmerge \
940 -nrecurse \
941 -predecessor \
942 -versions \
943 "
944 _diffcr="\
945 $_global_opts \
946 -ci \
947 -critical \
948 -element \
949 -flat \
950 -follow \
951 -long \
952 -name \
953 -nxname \
954 -recurse \
955 -select \
956 -short \
957 -type \
958 -view \
959 -wd \
960 "
961 _dospace_opts="\
962 $_global_opts \
963 -all \
964 -before \
965 -dump \
966 -generate \
967 -pool \
968 -references \
969 -region \
970 -scrub \
971 -since \
972 -size \
973 -top \
974 -update \
975 "
976 _find_opts="\
977 $_global_opts \
978 -all \
979 -avobs \
980 -branch \
981 -cview \
982 -depth \
983 -directory \
984 -element \
985 -exec \
986 -follow \
987 -group \
988 -kind \
989 -name \
990 -nrecurse \
991 -nvisible \
992 -nxname \
993 -ok \
994 -type \
995 -user \
996 -version \
997 -visible \
998 "
999 _mkelem_opts="\
1000 $_global_opts \
1001 -c \
1002 -cfile \
1003 -ci \
1004 -cq \
1005 -cqe \
1006 -eltype \
1007 -master \
1008 -mkpath \
1009 -nc \
1010 -nco \
1011 -nwarn \
1012 "
1013 _findmerge_opts="\
1014 $_global_opts \
1015 $_comment_opts \
1016 -abort \
1017 -all \
1018 -avobs \
1019 -blank \
1020 -depth \
1021 -directory \
1022 -element \
1023 -exec \
1024 -fbtag \
1025 -fcsets \
1026 -flatest \
1027 -follow \
1028 -ftag \
1029 -graphical \
1030 -group \
1031 -log \
1032 -long \
1033 -name \
1034 -nback \
1035 -nrecurse \
1036 -nxname \
1037 -nzero \
1038 -ok \
1039 -okgmerge \
1040 -okmerge \
1041 -qall \
1042 -qntrivial \
1043 -query \
1044 -serial \
1045 -short \
1046 -type \
1047 -unreserved \
1048 -user \
1049 -visible \
1050 -whynot \
1051 "
1052 _get_opts="\
1053 $_global_opts \
1054 -to \
1055 "
1056 _getcache_opts="\
1057 $_global_opts \
1058 -all \
1059 -host \
1060 -mvfs \
1061 -persistent \
1062 -reset \
1063 -short \
1064 -site \
1065 -view \
1066 "
1067 _ln_opts="\
1068 $_global_opts \
1069 $_comment_opts \
1070 -force \
1071 -nco \
1072 -slink \
1073 "
1074 _ls_opts="\
1075 $_global_opts \
1076 -directory \
1077 -long \
1078 -nxname \
1079 -recurse \
1080 -short \
1081 -view_only \
1082 -visibile \
1083 -vob_only \
1084 "
1085 _lscheckout_opts="\
1086 $_global_opts \
1087 -all \
1088 -areplicas \
1089 -avobs \
1090 -brtype \
1091 -cview \
1092 -directory \
1093 -fmt \
1094 -graphical \
1095 -long \
1096 -me \
1097 -recurse \
1098 -short \
1099 -user \
1100 "
1101 _lsdo_opts="\
1102 $_global_opts \
1103 -fmt \
1104 -long \
1105 -me \
1106 -nshareable_dos \
1107 -recurse \
1108 -short \
1109 -sname \
1110 -stime \
1111 -zero \
1112 "
1113 _lshistory_opts="\
1114 $_global_opts \
1115 -all \
1116 -avobs \
1117 -branch \
1118 -directory \
1119 -eventid \
1120 -fmt \
1121 -graphical \
1122 -last \
1123 -local \
1124 -long \
1125 -me \
1126 -minor \
1127 -nco \
1128 -nopreferences \
1129 -pname \
1130 -recurse \
1131 -short \
1132 -since \
1133 -user \
1134 "
1135 _lslock_opts="\
1136 $_global_opts \
1137 -all \
1138 -fmt \
1139 -local \
1140 -long \
1141 -obsolete \
1142 -pname \
1143 -short \
1144 "
1145 _lsmaster_opts="\
1146 $_global_opts \
1147 -all \
1148 -fmt \
1149 -inreplicas \
1150 -kind \
1151 -view \
1152 "
1153 _lsreplica_opts="\
1154 $_global_opts \
1155 -all \
1156 -fmt \
1157 -inreplicas \
1158 -invob \
1159 -long \
1160 -short \
1161 -siblings \
1162 "
1163 _lssite_opts="\
1164 $_global_opts \
1165 -inquire \
1166 -setting-name \
1167 "
1168 _lsstream_opts="\
1169 $_global_opts \
1170 -ancestor \
1171 -cview \
1172 -depth \
1173 -fmt \
1174 -in \
1175 -invob \
1176 -long \
1177 -obsolete \
1178 -recurse \
1179 -short \
1180 -template \
1181 -tree \
1182 -view \
1183 "
1184 _lsvtree_opts="\
1185 $_global_opts \
1186 -all \
1187 -branch \
1188 -graphical \
1189 -merge \
1190 -nco \
1191 -nmerge \
1192 -nrecurse \
1193 -obsolete \
1194 -short \
1195 "
1196 _merge_opts="\
1197 $_global_opts \
1198 -abort \
1199 -base \
1200 -c \
1201 -cfile \
1202 -columns \
1203 -cq \
1204 -cqe \
1205 -delete \
1206 -diff \
1207 -graphical \
1208 -insert \
1209 -narrows \
1210 -nc \
1211 -ndata \
1212 -options \
1213 -out \
1214 -qall \
1215 -qntrivial \
1216 -query \
1217 -replace \
1218 -serial \
1219 -tiny \
1220 -to \
1221 -version \
1222 "
1223 _mkattr_opts="\
1224 $_global_opts \
1225 $_comment_opts \
1226 -ci \
1227 -config \
1228 -default \
1229 -name \
1230 -pname \
1231 -replace \
1232 -select \
1233 -type \
1234 -version \
1235 "
1236 _mkattype_opts="\
1237 $_global_opts \
1238 $_comment_opts \
1239 -acquire \
1240 -default
1241 -enum \
1242 -ge \
1243 -global \
1244 -gt \
1245 -le
1246 -lt
1247 -ordinary \
1248 -replace \
1249 -shared \
1250 -vpbranch \
1251 -vpelement \
1252 -vpversion \
1253 -vtype \
1254 "
1255 _mkbranch_opts="\
1256 $_global_opts \
1257 $_comment_opts \
1258 -nco \
1259 -nwarn \
1260 -ptime \
1261 -version \
1262 "
1263 _mkbrtype_opts="\
1264 $_global_opts \
1265 -acquire \
1266 -global \
1267 -ordinary \
1268 -pbranch \
1269 -replace \
1270 "
1271 _mkdir_opts="\
1272 $_global_opts \
1273 $_comment_opts \
1274 -master \
1275 -nco \
1276 "
1277 _mkelem_opts="\
1278 $_global_opts \
1279 $_comment_opts \
1280 -ci \
1281 -eltype \
1282 -master \
1283 -mkpath \
1284 -nco \
1285 -nwarn \
1286 -ptime \
1287 "
1288 _mkeltype_opts="\
1289 $_global_opts \
1290 $_comment_opts \
1291 -acquire \
1292 -global \
1293 -manager \
1294 -mergetype \
1295 -ordinary \
1296 -ptime \
1297 -replace \
1298 -supertype \
1299 "
1300 _mkhlink_opts="\
1301 $_global_opts \
1302 $_comment_opts \
1303 -acquire \
1304 -fpname \
1305 -ftext \
1306 -tpname \
1307 -ttext \
1308 -unidir \
1309 "
1310 _mkhltype_opts="\
1311 $_global_opts \
1312 $_comment_opts \
1313 -acquire \
1314 -global \
1315 -ordinary \
1316 -replace \
1317 -shared \
1318 "
1319 _mklabel_opts="\
1320 $_global_opts \
1321 $_comment_opts \
1322 -ci \
1323 -config \
1324 -follow \
1325 -name \
1326 -nc \
1327 -recurse \
1328 -replace \
1329 -select \
1330 -type \
1331 -version \
1332 "
1333 _mklbtype_opts="\
1334 $_global_opts \
1335 $_comment_opts \
1336 -acquire \
1337 -global \
1338 -ordinary \
1339 -pbranch \
1340 -replace \
1341 -shared \
1342 "
1343 _mkpool_opts="\
1344 $_global_opts \
1345 $_comment_opts \
1346 -age \
1347 -alert \
1348 -cleartext \
1349 -ln \
1350 -size \
1351 -source \
1352 -update \
1353 "
1354 _mktrigger_opts="\
1355 $_global_opts \
1356 $_comment_opts \
1357 -force \
1358 -nattach \
1359 -ninherit \
1360 -recurse \
1361 "
1362 _move_opts="\
1363 $_global_opts \
1364 $_comment_opts \
1365 "
1366 _protect_opts="\
1367 $_global_opts \
1368 $_comment_opts \
1369 -chgrp \
1370 -chmod \
1371 -chown \
1372 -directory \
1373 -file \
1374 -pname \
1375 -recurse \
1376 "
1377 _protectvob_opts="\
1378 $_global_opts \
1379 -add_group \
1380 -chgrp \
1381 -chown \
1382 -delete_group \
1383 -force \
1384 -nremote_admin \
1385 -remote_admin \
1386 "
1387 _pwv_opts="\
1388 -root \
1389 -setview \
1390 -short \
1391 -wdview \
1392 "
1393 _relocate_opts="\
1394 $_global_opts \
1395 -force \
1396 -log \
1397 -qall \
1398 -update \
1399 "
1400 _rename_opts="\
1401 $_global_opts \
1402 $_comment_opts \
1403 -acquire \
1404 "
1405 _reqmaster_opts="\
1406 $_global_opts \
1407 $_comment_opts \
1408 -acl \
1409 -allow \
1410 -deny \
1411 -disable \
1412 -edit \
1413 -enable \
1414 -get \
1415 -instances \
1416 -list \
1417 -set \
1418 "
1419 _reserve_opts="\
1420 $_global_opts \
1421 $_comment_opts \
1422 -cact \
1423 "
1424 _rmbranch_opts="\
1425 $_global_opts \
1426 $_comment_opts \
1427 -force \
1428 "
1429 _rmdo_opts="\
1430 $_global_opts \
1431 -all \
1432 -before \
1433 -since \
1434 -zero \
1435 "
1436 _rmelem_opts="\
1437 $_global_opts \
1438 $_comment_opts \
1439 -force \
1440 "
1441 _rmmerge_opts="\
1442 $_global_opts \
1443 $_comment_opts \
1444 "
1445 _rmname_opts="\
1446 $_global_opts \
1447 $_comment_opts \
1448 -force \
1449 "
1450 _rmpool_opts="\
1451 $_global_opts \
1452 $_comment_opts \
1453 "
1454 _rmstream_opts="\
1455 $_global_opts \
1456 $_comment_opts \
1457 "
1458 _rmver_opts="\
1459 $_global_opts \
1460 $_comment_opts \
1461 -data \
1462 -force \
1463 -version \
1464 -vrange \
1465 -xattr \
1466 -xbranch \
1467 -xhlink \
1468 -xlabel \
1469 "
1470 _schedule_opts="\
1471 $_global_opts \
1472 -acl \
1473 -delete \
1474 -edit \
1475 -force \
1476 -get \
1477 -host \
1478 -job \
1479 -run \
1480 -schedule \
1481 -set \
1482 -status \
1483 -tasks \
1484 -wait \
1485 "
1486 _setactivity_opts="\
1487 $_global_opts \
1488 $_comment_opts \
1489 -none \
1490 -view \
1491 "
1492 _setcache_opts="\
1493 $_global_opts \
1494 -acache \
1495 -cachesize \
1496 -cto \
1497 -cview \
1498 -cvpfreemax \
1499 -cvpfreemin \
1500 -default \
1501 -dirdnc \
1502 -dncache \
1503 -host \
1504 -mnmax \
1505 -mvfs \
1506 -nacache \
1507 -ncto \
1508 -ndncachez \
1509 -noentdnc \
1510 -nrlcache \
1511 -nrvcache \
1512 -password \
1513 -persistent \
1514 -persistent_only \
1515 -readdir_blocks \
1516 -regdnc \
1517 -rlcache \
1518 -rpchandles \
1519 -rvcache \
1520 -scalefactor \
1521 -site \
1522 -view \
1523 -vobfreemax \
1524 -vobfreemin \
1525 -zone \
1526 "
1527 _setsite_opts="\
1528 $_global_opts \
1529 -password \
1530 "
1531 _uncheckout_opts="\
1532 $_global_opts \
1533 -cact \
1534 -keep \
1535 -rm \
1536 -unco \
1537 "
1538 _unregister_opts="\
1539 $_global_opts \
1540 -uuid \
1541 -view \
1542 -vob \
1543 "
1544 _unreserve_opts="\
1545 $_global_opts \
1546 $_comment_opts \
1547 -cact \
1548 -view \
1549 "
1550 _update_opts="\
1551 $_global_opts \
1552 -add_loadrules \
1553 -ctime \
1554 -force \
1555 -graphical \
1556 -log \
1557 -noverwrite \
1558 -overwrite \
1559 -print \
1560 -ptime \
1561 -rename \
1562 "
1563 _winkin_opts="\
1564 $_global_opts \
1565 -adirs \
1566 -adirs \
1567 -ci \
1568 -noverwrite \
1569 -out \
1570 -print \
1571 -recurse \
1572 -select \
1573 -siblings \
1574 "
1575
1576 _object_selectors="\
1577 activity: \
1578 attype: \
1579 baseline: \
1580 brtype: \
1581 component: \
1582 eltype: \
1583 folder: \
1584 hlink: \
1585 hltype: \
1586 lbtype: \
1587 oid: \
1588 pool: \
1589 project: \
1590 replica: \
1591 stream: \
1592 trtype: \
1593 vob: \
1594 "
1595
1596 _operation_types="\
1597 chactivity \
1598 chbl \
1599 checkin \
1600 checkout \
1601 chevent \
1602 chfolder \
1603 chmaster \
1604 chproject \
1605 chstream \
1606 chtype \
1607 deliver_cancel \
1608 deliver_complete \
1609 deliver_start \
1610 lnname \
1611 lock \
1612 mkactivity \
1613 mkattr \
1614 mkbl \
1615 mkbl_complete \
1616 mkbranch \
1617 mkcomp \
1618 mkelem \
1619 mkfolder \
1620 mkhlink \
1621 mklabel \
1622 mkproject \
1623 mkslink \
1624 mkstream \
1625 mktrigger \
1626 protect \
1627 rebase_cancel \
1628 rebase_complete \
1629 rebase_start \
1630 reserve \
1631 rmactivity \
1632 rmattr \
1633 rmbranch \
1634 rmcl \
1635 rmcomp \
1636 rmelem \
1637 rmfolder \
1638 rmhlink \
1639 rmlabel \
1640 rmname \
1641 rmproject \
1642 rmstream \
1643 rmtrigger \
1644 rmver \
1645 setactivity \
1646 setactivity_none \
1647 setplevel \
1648 uncheckout \
1649 unlock \
1650 unreserve \
1651 "
1652
1653 if [ $ARCHITECTURE = 'cygwin' ]; then
1654   _arch_policies="\
1655 POLICY_WIN_INT_SNAP \
1656 POLICY_WIN_DEV_SNAP \
1657 "
1658 else
1659   _arch_policies="\
1660 POLICY_UNIX_INT_SNAP \
1661 POLICY_UNIX_DEV_SNAP \
1662 "
1663 fi
1664
1665 _policies="\
1666 $arch_policies \
1667 POLICY_CHPROJECT_UNRESTRICED \
1668 POLICY_DELIVER_REQUIRE_REBASE \
1669 POLICY_DELIVER_NCO_DEVSTR \
1670 POLICY_DELIVER_NOCO_SELACTS \
1671 POLICY_REBASE_CO \
1672 POLICY_INTRAPROJECT_DELIVER_FOUNDATION_CHANGES \
1673 POLICY_INTRAPROJECT_DELIVER_ALLOW_MISSING_TGTCOMPS \
1674 POLICY_INTERPROJECT_DELIVER \
1675 POLICY_INTERPROJECT_DELIVER_FOUNDATION_CHANGES \
1676 POLICY_INTERPROJECT_DELIVER_REQUIRE_TGTCOMP_VISIBIITY \
1677 POLICY_INTERPROJECT_DELIVER_ALLOW_NONMOD_TGTCOMPS \
1678 "
1679
1680 # Helper functions
1681 function set_pvob () {
1682   if [ $# -eq 1 ]; then
1683         pvob=$1
1684   fi
1685 } # set_pvob
1686
1687 function set_dvob () {
1688   if [ $# -eq 1 ]; then
1689         dvob=$1
1690   fi
1691 } # set_dvob
1692
1693 # Listing type functions. These functions produce a list of some object and are
1694 # used by the various completion functions.
1695 function _attypes () {
1696   if [ $# -gt 0 ]; then
1697         scm lstype -kind attype -invob $pvob -fmt "%n " | grep ^$1
1698   else
1699     scm lstype -kind attype -invob $pvob -fmt "%n "
1700   fi
1701 } # _attypes
1702
1703 function _activities () {
1704   if [ $# -gt 0 ]; then
1705         scm lsactivity -short -invob $pvob | grep ^$1 | sed "s:$:@$vobtagPrefix$pvob:"
1706   else
1707     scm lsactivity -short -invob $pvob | sed "s:$:@$vobtagPrefix$pvob:"
1708   fi
1709 } # _activities
1710
1711 function _baselines () {
1712   stream=$(scm lsstream -short 2> /dev/null)
1713   
1714   if [ -z $stream ]; then
1715         return;
1716   fi
1717   
1718   if [ $# -ge 0 ]; then
1719         scm lsbl -stream $stream@$pvob -short | grep ^$1 | sed "s:$:@$vobtagPrefix$pvob:"
1720   else 
1721         scm lsbl -stream $stream@$pvob -short | sed "s:$:@$vobtagPrefix$pvob:"
1722   fi
1723 } # _baselines
1724
1725 function _brtypes () {
1726   if [ $# -gt 0 ]; then
1727         scm lstype -kind brtype -invob $pvob -fmt "%n\n" | grep ^$1
1728   else
1729     scm lstype -kind brtype -invob $pvob -fmt "%n\n"
1730   fi
1731 } # _brtypes
1732
1733 function _cchosts () {
1734   registryHost=$(scm hostinfo -long | grep "Registry host:" | awk '{print $NF}')
1735
1736   scm lsclients -short -host $registryHost | tr [:upper:] [:lower:]
1737 } # _cchosts
1738
1739 function _components () {
1740   if [ $# -gt 0 ]; then
1741         scm lscomp -short -invob $pvob | grep ^$1 | sed "s:$:@$vobtagPrefix$pvob:"
1742   else
1743         scm lscomp -short -invob $pvob | sed "s:$:@$vobtagPrefix$pvob:"
1744   fi
1745 } # _components
1746
1747 function _eltypes () {
1748   if [ $# -gt 0 ]; then
1749         scm lstype -kind eltype -invob $pvob -fmt "%n " | grep ^$1
1750   else
1751     scm lstype -kind eltype -invob $pvob -fmt "%n "
1752   fi
1753 } # _eltypes
1754
1755 function _folders () {
1756   if [ $# -gt 0 ]; then
1757         scm lsfolder -short -invob $pvob | grep ^$1 | sed "s:$:@$vobtagPrefix$pvob:"
1758   else
1759     scm lsfolder -short -invob $pvob | sed "s:$:@$vobtagPrefix$pvob:"
1760   fi
1761 } # _folders
1762
1763 function _hltypes () {
1764   if [ $# -gt 0 ]; then
1765         scm lstype -kind hltype -invob $pvob -fmt "%n " | grep ^$1
1766   else
1767     scm lstype -kind hltype -invob $pvob -fmt "%n "
1768   fi
1769 } # _hltypes
1770
1771 function _lbtypes () {
1772   if [ $# -gt 0 ]; then
1773         scm lstype -kind lbtype -invob $pvob -fmt "%n@$vobtagPrefix$pvob " | grep ^$1
1774   else
1775     scm lstype -kind lbtype -invob $pvob -fmt "%n@$vobtagPrefix$pvob "
1776   fi
1777 } # _lbtypes
1778
1779 function _projects () {
1780   if [ $# -gt 0 ]; then
1781         scm lsproject -short -invob $pvob | grep ^$1 | sed "s:$:@$vobtagPrefix$pvob:"
1782   else
1783         scm lsproject -short -invob $pvob | sed "s:$:@$vobtagPrefix$pvob:"
1784   fi    
1785 } # _projects
1786
1787 function _streams () {
1788   if [ $# -gt 0 ]; then
1789         scm lsstream -short -invob $pvob | grep ^$1 | sed "s:$:@$vobtagPrefix$pvob:"
1790   else
1791         scm lsstream -short -invob $pvob | sed "s:$:@$vobtagPrefix$pvob:"
1792   fi
1793 } # _streams
1794
1795 function _stglocs () {
1796   if [ $# -gt 0 ]; then
1797         scm lsstgloc -short | grep ^$1
1798   else
1799         scm lsstgloc -short
1800   fi
1801 } # _stglocs
1802
1803 function _views () {
1804   if [ $# -gt 0 ]; then
1805     scm lsview -short | grep ^$1;
1806   else
1807     scm lsview -short;
1808   fi
1809 } # _views
1810
1811 function _vobs () {
1812   # We simply must rid ourselves of these bloody backlashes!!! And yet Clearcase
1813   # insists on retaining them. Let's strip them off, do our thing, then put them
1814   # back to backslashes when we output stuff.
1815   if [ $ARCHITECTURE = 'cygwin' ]; then
1816         if [ $# -eq 0 ]; then
1817           scm lsvob -short | sed 's:\\:\\\\\\\\:'
1818         else
1819       # Convert to foward slashes
1820       vob=$(echo $1 | sed 's:\\::g')
1821       
1822       scm lsvob -short | sed 's:\\::' | grep ^$vob | sed 's:^:\\\\\\\\:'
1823         fi
1824   else
1825     if [ $# -eq 0 ]; then
1826       scm lsvob -short
1827     else
1828       scm lsvob -short | grep ^$1
1829     fi
1830   fi
1831 } # _vobs
1832
1833 function _trtypes () {
1834   if [ $# -gt 0 ]; then
1835         scm lstype -kind trtype -invob $pvob -fmt "%n " | grep ^$1
1836   else
1837     scm lstype -kind trtype -invob $pvob -fmt "%n "
1838   fi
1839 } # _trtypes
1840
1841 # Completion functions for individual commands where the completion may change
1842 # depending on the operation. For example, typing "scm catcs -tag " should
1843 # now complete based on view tags whereas "scm catcs -" should just complete
1844 # based on options (which are only -help and -tag at this point for this 
1845 # particular command). If a command does not have a "completer function" then
1846 # it will only provide for options completion and will be handled by the general
1847 # _scm completion function.
1848 function _catcs () {
1849   local cur prev
1850   local opts="\
1851 $_global_opts \
1852 -tag \
1853 "
1854   COMPREPLY=()
1855   cur="${COMP_WORDS[COMP_CWORD]}"
1856   prev="${COMP_WORDS[COMP_CWORD-1]}"
1857
1858   if [[ $cur == -* ]]; then
1859     COMPREPLY=($(compgen -W "$opts" -- $cur))
1860   elif [[ $prev == -tag ]]; then
1861         COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
1862   fi
1863 } # _catcs
1864
1865 function _chactivity () {
1866   local cur prev
1867   local opts="\
1868 $_global_opts \
1869 $_comment_opts \
1870 -headline \
1871 -fcset \
1872 -tcset \
1873 -view \
1874 -cqaction \
1875 -cact \
1876 "
1877   COMPREPLY=()
1878   cur="${COMP_WORDS[COMP_CWORD]}"
1879   prev="${COMP_WORDS[COMP_CWORD-1]}"
1880   
1881   if [[ $cur == -* ]]; then
1882     COMPREPLY=($(compgen -W "$opts" -- $cur))
1883   elif [[ $prev == -fcset || $prev == -tcset ]]; then
1884         COMPREPLY=($(compgen -W "$(_activities $cur)"))
1885   elif [[ $prev == -view ]]; then
1886     COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
1887   fi    
1888 } # _chactivity
1889
1890 function _checkin () {
1891   local cur prev prev2
1892   local opts="\
1893 $_global_opts \
1894 $_comment_opts \
1895 -cact \
1896 -cr \
1897 -from \
1898 -identical \
1899 -keep \
1900 -ptime \
1901 -rm \
1902 "
1903   COMPREPLY=()
1904   cur="${COMP_WORDS[COMP_CWORD]}"
1905   prev="${COMP_WORDS[COMP_CWORD-1]}"
1906   prev2="${COMP_WORDS[COMP_CWORD-2]}"
1907   
1908   if [[ $cur == -* ]]; then
1909     COMPREPLY=($(compgen -W "$opts" -- $cur))
1910   elif [[ $prev2 == activity && $prev == : ]]; then
1911         COMPREPLY=($(compgen -W "$(_activities $cur)"))
1912   fi            
1913 } # _checkin
1914
1915 function _checkvob () {
1916   local cur prev
1917   local opts="\
1918 $_global_opts \
1919 -acquire \
1920 -activity \
1921 -cleartext \
1922 -component \
1923 -crm \
1924 -data \
1925 -debris \
1926 -derived \
1927 -fix \
1928 -force \
1929 -from \
1930 -global \
1931 -hlinks \
1932 -hltype \
1933 -ignore \
1934 -lock \
1935 -log \
1936 -pname \
1937 -pool \
1938 -protections \
1939 -setup \
1940 -source \
1941 -to \
1942 -trssize \
1943 -ucm \
1944 -unlock \
1945 -verbose \
1946 -view \
1947 -vob \
1948 "
1949   COMPREPLY=()
1950   cur="${COMP_WORDS[COMP_CWORD]}"
1951   prev="${COMP_WORDS[COMP_CWORD-1]}"
1952
1953   if [[ $cur == -* ]]; then
1954     COMPREPLY=($(compgen -W "$opts" -- $cur))
1955   elif [[ $prev == -view ]]; then
1956     COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
1957   fi                    
1958 } # _checkvob
1959
1960 function _chevent () {
1961   local cur prev
1962   local opts="\
1963 $_global_opts \
1964 $_comment_opts \
1965 -append \
1966 -event \
1967 -insert \
1968 -invob \
1969 -pname \
1970 -replace \
1971 "
1972   COMPREPLY=()
1973   cur="${COMP_WORDS[COMP_CWORD]}"
1974   prev="${COMP_WORDS[COMP_CWORD-1]}"
1975
1976   if [[ $cur == -* ]]; then
1977     COMPREPLY=($(compgen -W "$opts" -- $cur))
1978   elif [[ $prev == -invob ]]; then
1979     COMPREPLY=($(compgen -W "$(_vobs $cur)"))
1980   elif [[ $cur == * ]]; then
1981     COMPREPLY=($(compgen -W "$_object_selectors" -- $cur))
1982   fi
1983 } # _chevent
1984
1985 function _chfolder () {
1986   local cur prev
1987   local opts="\
1988 $_global_opts \
1989 $_comment_opts \
1990 -to \
1991 "
1992   COMPREPLY=()
1993   cur="${COMP_WORDS[COMP_CWORD]}"
1994   prev="${COMP_WORDS[COMP_CWORD-1]}"
1995
1996   if [[ $cur == -* ]]; then
1997     COMPREPLY=($(compgen -W "$opts" -- $cur))
1998   elif [[ $prev == -to ]]; then
1999     COMPREPLY=($(compgen -W "$(_folders $cur)"))
2000   elif [[ $cur == * ]]; then
2001     COMPREPLY=($(compgen -W "$(_folders $cur)"))
2002   fi
2003 } # _chfolder
2004
2005 function _chmaster () {
2006   local cur prev
2007   local opts="\
2008 $_global_opts \
2009 $_comment_opts \
2010 -all \
2011 -default \
2012 -long \
2013 -obsolete_replica \
2014 -override \
2015 -pname \
2016 -stream \
2017 -view \
2018 "
2019   COMPREPLY=()
2020   cur="${COMP_WORDS[COMP_CWORD]}"
2021   prev="${COMP_WORDS[COMP_CWORD-1]}"
2022
2023   if [[ $cur == -* ]]; then
2024     COMPREPLY=($(compgen -W "$opts" -- $cur))
2025   elif [[ $prev == -stream ]]; then
2026     COMPREPLY=($(compgen -W "$(_streams $cur)"))
2027   elif [[ $cur == -view ]]; then
2028     COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
2029   fi
2030 } # _chmaster
2031
2032 function _chproject () {
2033   local cur prev
2034   local opts="\
2035 $_global_opts \
2036 $_comment_opts \
2037 -amodcomp \
2038 -blname \
2039 -connection \
2040 -crmenable \
2041 -custom \
2042 -dmodcomp \
2043 -ncrmenable \
2044 -npolicy \
2045 -policy \
2046 -rebase \
2047 -spolicy \
2048 -template \
2049 -to \
2050 "
2051   COMPREPLY=()
2052   cur="${COMP_WORDS[COMP_CWORD]}"
2053   prev="${COMP_WORDS[COMP_CWORD-1]}"
2054
2055   if [[ $cur == -* ]]; then
2056     COMPREPLY=($(compgen -W "$opts" -- $cur))
2057   elif [[ $prev == -amodcomp ||
2058           $prev == -dmodcomp ]]; then
2059     COMPREPLY=($(compgen -W "$(_components $cur)"))
2060   elif [[ $prev == -to ]]; then
2061     COMPREPLY=($(compgen -W "$(_folders $cur)"))
2062   elif [[ $prev == -policy  ||
2063           $prev == -npolicy ||
2064           $prev == -spolicy ]]; then
2065     COMPREPLY=($(compgen -W "$_policies" -- $cur))
2066   elif [[ $cur == * ]]; then
2067     COMPREPLY=($(compgen -W "$(_projects $cur)"))
2068   fi
2069 } # _chproject
2070
2071 function _chstream () {
2072   local cur prev
2073   local opts="\
2074 $_global_opts \
2075 $_comment_opts \
2076 -amodcomp \
2077 -cview \
2078 -default \
2079 -dmodcomp \
2080 -generate \
2081 -npolicy \
2082 -nrecommended \
2083 -ntarget \
2084 -policy \
2085 -recommended \
2086 -target \
2087 -template \
2088 "
2089   COMPREPLY=()
2090   cur="${COMP_WORDS[COMP_CWORD]}"
2091   prev="${COMP_WORDS[COMP_CWORD-1]}"
2092
2093   if [[ $cur == -* ]]; then
2094     COMPREPLY=($(compgen -W "$opts" -- $cur))
2095   elif [[ $prev == -amodcomp ||
2096           $prev == -dmodcomp ]]; then
2097     COMPREPLY=($(compgen -W "$(_components $cur)"))
2098   elif [[ $prev == -policy  ||
2099           $prev == -npolicy ]]; then
2100     COMPREPLY=($(compgen -W "$_policies" -- $cur))
2101   elif [[ $prev == , || $prev == -recommended || $cur == , ]]; then
2102     if [[ $cur == , ]]; then
2103       cur=''
2104     fi
2105     COMPREPLY=($(compgen -W "$(_baselines $cur)"))
2106   elif [[ $prev == -target || $cur == * ]]; then
2107     COMPREPLY=($(compgen -W "$(_streams $cur)"))
2108   fi
2109 } # _chstream
2110
2111 function _chview () {
2112   local cur prev
2113   local opts="\
2114 $_global_opts \
2115 -cachesize \
2116 -cview \
2117 -force \
2118 -nshareable \
2119 -readonly \
2120 -readwrite \
2121 -shareable \
2122 -stream \
2123 "
2124   COMPREPLY=()
2125   cur="${COMP_WORDS[COMP_CWORD]}"
2126   prev="${COMP_WORDS[COMP_CWORD-1]}"
2127
2128   if [[ $cur == -* ]]; then
2129     COMPREPLY=($(compgen -W "$opts" -- $cur))
2130   elif [[ $prev == -stream ]]; then
2131     COMPREPLY=($(compgen -W "$(_streams $cur)"))
2132   elif [[ $prev == * ]]; then
2133     COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
2134   fi
2135 } # _chview
2136
2137 function _deliver () {
2138   local cur prev
2139   local opts="\
2140 $_global_opts \
2141 -activities \
2142 -cact \
2143 -complete \
2144 -force \
2145 -gmerge \
2146 -graphical \
2147 -query \
2148 -reset \
2149 -serial \
2150 -stream \
2151 -target \
2152 -to \
2153 "
2154   COMPREPLY=()
2155   cur="${COMP_WORDS[COMP_CWORD]}"
2156   prev="${COMP_WORDS[COMP_CWORD-1]}"
2157
2158   if [[ $cur == -* ]]; then
2159     COMPREPLY=($(compgen -W "$opts" -- $cur))
2160   elif [[ $prev == -stream || $prev == -target ]]; then
2161     COMPREPLY=($(compgen -W "$(_streams $cur)"))
2162   elif [[ $prev == -to ]]; then
2163     COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
2164   elif [[ $prev == -activities ]]; then
2165         COMPREPLY=($(compgen -W "$(_activities $cur)"))
2166   fi
2167 } # _deliver
2168
2169 function _describe () {
2170   local cur prev
2171   local opts="\
2172 $_global_opts \
2173 -aattr \
2174 -ahlink \
2175 -alabel \
2176 -aliases \
2177 -all \
2178 -cact \
2179 -cview \
2180 -graphical \
2181 -ihlink \
2182 -local \
2183 -long \
2184 -pname \
2185 -predecessor \
2186 -type \
2187 -version \
2188 "
2189   COMPREPLY=()
2190   cur="${COMP_WORDS[COMP_CWORD]}"
2191   prev="${COMP_WORDS[COMP_CWORD-1]}"
2192
2193   if [[ $cur == -* ]]; then
2194     COMPREPLY=($(compgen -W "$opts" -- $cur))
2195   elif [[ $cur == * ]]; then
2196     COMPREPLY=($(compgen -W "$_object_selectors" -- $cur))
2197   fi
2198 } # _describe
2199
2200 function _dospace () {
2201   local cur prev
2202   local opts="\
2203 $_global_opts \
2204 -before \
2205 -pool \
2206 -references \
2207 -region \
2208 -scrub \
2209 -since \
2210 -size \
2211 -top \
2212 -update \
2213 "
2214   COMPREPLY=()
2215   cur="${COMP_WORDS[COMP_CWORD]}"
2216   prev="${COMP_WORDS[COMP_CWORD-1]}"
2217
2218   if [[ $cur == -* ]]; then
2219     COMPREPLY=($(compgen -W "$opts" -- $cur))
2220   elif [[ $prev == -region ]]; then
2221     COMPREPLY=($(compgen -W "$(lsregions)" -- $cur))
2222   fi
2223 } # _dospace
2224
2225 function _edcs () {
2226   local cur prev
2227   local opts="\
2228 $_global_opts \
2229 -ctime \
2230 -overwrite \
2231 -ptime \
2232 -rename \
2233 -tag \
2234 "
2235   COMPREPLY=()
2236   cur="${COMP_WORDS[COMP_CWORD]}"
2237   prev="${COMP_WORDS[COMP_CWORD-1]}"
2238
2239   if [[ $cur == -* ]]; then
2240     COMPREPLY=($(compgen -W "$opts" -- $cur))
2241   elif [[ $prev == -tag ]]; then
2242     COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
2243   fi
2244 } # _edcs
2245
2246 function _endview () {
2247   local cur prev
2248   local opts="\
2249 $_global_opts \
2250 -server \
2251 "
2252   COMPREPLY=()
2253   cur="${COMP_WORDS[COMP_CWORD]}"
2254   prev="${COMP_WORDS[COMP_CWORD-1]}"
2255
2256   if [[ $cur == -* ]]; then
2257     COMPREPLY=($(compgen -W "$opts" -- $cur))
2258   elif [[ $prev == * ]]; then
2259     COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
2260   fi
2261 } # _endview
2262
2263 function _file () {
2264   local cur prev
2265   local opts="\
2266 $_global_opts \
2267 -all \
2268 -invob \
2269 "
2270   COMPREPLY=()
2271   cur="${COMP_WORDS[COMP_CWORD]}"
2272   prev="${COMP_WORDS[COMP_CWORD-1]}"
2273
2274   if [[ $cur == -* ]]; then
2275     COMPREPLY=($(compgen -W "$opts" -- $cur))
2276   elif [[ $prev == -invob ]]; then
2277     COMPREPLY=($(compgen -W "$(_vobs $cur)"))
2278   fi
2279 } # _file
2280
2281 function _getlog () {
2282   local cur prev
2283   local opts="\
2284 $_global_opts \
2285 -all \
2286 -around \
2287 -cview \
2288 -full \
2289 -graphical \
2290 -host \
2291 -inquire \
2292 -last \
2293 -since \
2294 -tag \
2295 -vob \
2296 "
2297   COMPREPLY=()
2298   cur="${COMP_WORDS[COMP_CWORD]}"
2299   prev="${COMP_WORDS[COMP_CWORD-1]}"
2300
2301   if [[ $cur == -* ]]; then
2302     COMPREPLY=($(compgen -W "$opts" -- $cur))
2303   elif [[ $prev == -tag || $prev == -target ]]; then
2304     COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
2305   elif [[ $prev == -vob ]]; then
2306     COMPREPLY=($(compgen -W "$(_vobs $cur)"))
2307   elif [[ $prev == -host ]]; then
2308     COMPREPLY=($(compgen -W "$(_cchosts)" -- $cur))
2309   fi
2310 } # _getlog
2311
2312 function _hostinfo () {
2313   local cur prev
2314   local opts="\
2315 $_global_opts \
2316 -full \
2317 -long \
2318 -properties \
2319 "
2320   COMPREPLY=()
2321   cur="${COMP_WORDS[COMP_CWORD]}"
2322   prev="${COMP_WORDS[COMP_CWORD-1]}"
2323
2324   if [[ $cur == -* ]]; then
2325     COMPREPLY=($(compgen -W "$opts" -- $cur))
2326   elif [[ $cur == * ]]; then
2327         COMPREPLY=($(compgen -W "$(_cchosts)" -- $cur))
2328   fi
2329 } # _hostinfo
2330
2331 function _lsactivity () {
2332   local cur prev
2333   local opts="\
2334 $_global_opts \
2335 -ancestor \
2336 -cact \
2337 -contrib \
2338 -cview \
2339 -depth \
2340 -fmt \
2341 -fmt \
2342 -in \
2343 -invob \
2344 -long \
2345 -me \
2346 -obsolete \
2347 -recurse \
2348 -short \
2349 -user \
2350 -view \
2351 "
2352   COMPREPLY=()
2353   cur="${COMP_WORDS[COMP_CWORD]}"
2354   prev="${COMP_WORDS[COMP_CWORD-1]}"
2355
2356   if [[ $cur == -* ]]; then
2357     COMPREPLY=($(compgen -W "$opts" -- $cur))
2358   elif [[ $prev == -invob ]]; then
2359     COMPREPLY=($(compgen -W "$(_vobs $cur)"))
2360   elif [[ $prev == -in ]]; then
2361     COMPREPLY=($(compgen -W "$(_streams $cur)"))  
2362   elif [[ $prev == -view ]]; then
2363     COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
2364   elif [[ $cur == * ]]; then
2365         COMPREPLY=($(compgen -W "$(_activities $cur)"))
2366   fi
2367 } # _lsactivity
2368
2369 function _lsbl () {
2370   local cur prev
2371   local opts="\
2372 $_global_opts \
2373 -component \
2374 -cview \
2375 -fmt \
2376 -gtlevel \
2377 -level \
2378 -long \
2379 -long \
2380 -ltlevel \
2381 -obsolete \
2382 -recurse \
2383 -short \
2384 -stream \
2385 -tree \
2386 "
2387   COMPREPLY=()
2388   cur="${COMP_WORDS[COMP_CWORD]}"
2389   prev="${COMP_WORDS[COMP_CWORD-1]}"
2390
2391   if [[ $cur == -* ]]; then
2392     COMPREPLY=($(compgen -W "$opts" -- $cur))
2393   elif [[ $prev == -component ]]; then
2394     COMPREPLY=($(compgen -W "$(_components $cur)"))
2395   elif [[ $prev == -stream ]]; then
2396     COMPREPLY=($(compgen -W "$(_streams $cur)"))  
2397   fi
2398 } # _lsbl
2399
2400 function _lsclients () {
2401   local cur prev
2402   local opts="\
2403 $_global_opts \
2404 -host \
2405 -type \
2406 -short \
2407 -long \
2408 "
2409   COMPREPLY=()
2410   cur="${COMP_WORDS[COMP_CWORD]}"
2411   prev="${COMP_WORDS[COMP_CWORD-1]}"
2412
2413   if [[ $cur == -* ]]; then
2414     COMPREPLY=($(compgen -W "$opts" -- $cur))
2415   elif [[ $prev == -host ]]; then
2416         COMPREPLY=($(compgen -W "$(_cchosts $cur)"))
2417   fi
2418 } # _lsclients
2419
2420 function _lscomp () {
2421   local cur prev
2422   local opts="\
2423 $_global_opts \
2424 -fmt \
2425 -invob \
2426 -long \
2427 -obsolete \
2428 -short \
2429 -tree \
2430 "
2431   COMPREPLY=()
2432   cur="${COMP_WORDS[COMP_CWORD]}"
2433   prev="${COMP_WORDS[COMP_CWORD-1]}"
2434
2435   if [[ $cur == -* ]]; then
2436     COMPREPLY=($(compgen -W "$opts" -- $cur))
2437   elif [[ $prev == -invob ]]; then
2438     COMPREPLY=($(compgen -W "$(_vobs $cur)"))
2439   elif [[ $cur == * ]]; then
2440     COMPREPLY=($(compgen -W "$(_components $cur)"))
2441   fi
2442 } # _lscomp
2443
2444 function _lsfolder () {
2445   local cur prev
2446   local opts="\
2447 $_global_opts \
2448 -ancestor \
2449 -cview \
2450 -depth \
2451 -fmt \
2452 -in \
2453 -invob \
2454 -obsolete \
2455 -recurse \
2456 -short \
2457 -tree \
2458 -view \
2459 "
2460   local lopts="$opts -long"
2461   COMPREPLY=()
2462   cur="${COMP_WORDS[COMP_CWORD]}"
2463   prev="${COMP_WORDS[COMP_CWORD-1]}"
2464
2465   if [[ $cur == -* ]]; then
2466         if [[ $prev == -llfolder ]]; then
2467       COMPREPLY=($(compgen -W "$opts" -- $cur))
2468         else
2469       COMPREPLY=($(compgen -W "$lopts" -- $cur))
2470         fi
2471   elif [[ $prev == -invob ]]; then
2472     COMPREPLY=($(compgen -W "$(_vobs $cur)"))
2473   elif [[ $prev == -view ]]; then
2474     COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
2475   elif [[ $prev == -in || $cur == * ]]; then
2476     COMPREPLY=($(compgen -W "$(_folders $cur)"))
2477   fi
2478 } # _lsfolder
2479
2480 function _lspool () {
2481   local cur prev
2482   local opts="\
2483 $_global_opts \
2484 -fmt \
2485 -invob \
2486 -long \
2487 -obsolete \
2488 -short \
2489 "
2490   COMPREPLY=()
2491   cur="${COMP_WORDS[COMP_CWORD]}"
2492   prev="${COMP_WORDS[COMP_CWORD-1]}"
2493
2494   if [[ $cur == -* ]]; then
2495     COMPREPLY=($(compgen -W "$opts" -- $cur))
2496   elif [[ $prev == -invob ]]; then
2497     COMPREPLY=($(compgen -W "$(_vobs $cur)"))
2498   fi
2499 } # _lspool
2500
2501 function _lsprivate () {
2502   local cur prev
2503   local opts="\
2504 $_global_opts \
2505 -age \
2506 -co \
2507 -do \
2508 -invob \
2509 -long \
2510 -other \
2511 -short \
2512 -size \
2513 -tag \
2514 "
2515   COMPREPLY=()
2516   cur="${COMP_WORDS[COMP_CWORD]}"
2517   prev="${COMP_WORDS[COMP_CWORD-1]}"
2518
2519   if [[ $cur == -* ]]; then
2520     COMPREPLY=($(compgen -W "$opts" -- $cur))
2521   elif [[ $prev == -tag ]]; then
2522     COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
2523   elif [[ $prev == -invob ]]; then
2524     COMPREPLY=($(compgen -W "$(_vobs $cur)"))
2525   fi
2526 } # _lsprivate
2527
2528 function _lsproject () {
2529   local cur prev
2530   local opts="\
2531 $_global_opts \
2532 -ancestor \
2533 -custom \
2534 -cview \
2535 -depth \
2536 -fmt \
2537 -in \
2538 -invob \
2539 -long \
2540 -obsolete \
2541 -recurse \
2542 -short \
2543 -template \
2544 -tree \
2545 -view \
2546 "
2547   COMPREPLY=()
2548   cur="${COMP_WORDS[COMP_CWORD]}"
2549   prev="${COMP_WORDS[COMP_CWORD-1]}"
2550
2551   if [[ $cur == -* ]]; then
2552     COMPREPLY=($(compgen -W "$opts" -- $cur))
2553   elif [[ $prev == -view ]]; then
2554     COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
2555   elif [[ $prev == -invob ]]; then
2556     COMPREPLY=($(compgen -W "$(_vobs $cur)"))
2557   elif [[ $prev == -in || $cur == * ]]; then
2558     COMPREPLY=($(compgen -W "$(_folders $cur)"))  
2559   fi
2560 } # _lsproject
2561
2562 function _lsregion () {
2563   local cur prev
2564   local opts="\
2565 $_global_opts \
2566 -long \
2567 -short \
2568 "
2569   COMPREPLY=()
2570   cur="${COMP_WORDS[COMP_CWORD]}"
2571   prev="${COMP_WORDS[COMP_CWORD-1]}"
2572
2573   if [[ $cur == -* ]]; then
2574     COMPREPLY=($(compgen -W "$opts" -- $cur))
2575   elif [[ $prev == * ]]; then
2576     regions=$(scm lsregion -short | grep ^$cur)
2577     COMPREPLY=($(compgen -W "$regions" -- $cur))
2578   fi
2579 } # _lsregion
2580
2581 function _lsstgloc () {
2582   local cur prev
2583   local opts="\
2584 $_global_opts \
2585 -host \
2586 -long \
2587 -region \
2588 -short \
2589 -storage \
2590 -view \
2591 -vob \
2592 "
2593   COMPREPLY=()
2594   cur="${COMP_WORDS[COMP_CWORD]}"
2595   prev="${COMP_WORDS[COMP_CWORD-1]}"
2596
2597   if [[ $cur == -* ]]; then
2598     COMPREPLY=($(compgen -W "$opts" -- $cur))
2599   elif [[ $prev == -region ]]; then
2600     COMPREPLY=($(compgen -W "$(_regions $cur)" -- $cur))
2601   elif [[ $prev == -storage ]]; then
2602     COMPREPLY=($(compgen -W "$(_stglocs $cur)"))
2603   elif [[ $prev == -host ]]; then
2604     _cchosts
2605   fi
2606 } # _lsstgloc
2607
2608 function _lsstream () {
2609   local cur prev
2610   local opts="\
2611 $_global_opts \
2612 -ancestor \
2613 -cview \
2614 -depth \
2615 -fmt \
2616 -in \
2617 -invob \
2618 -obsolete \
2619 -recurse \
2620 -short \
2621 -template \
2622 -tree \
2623 -view \
2624 "
2625   local lopts="$opts -long"
2626   COMPREPLY=()
2627   cur="${COMP_WORDS[COMP_CWORD]}"
2628   prev="${COMP_WORDS[COMP_CWORD-1]}"
2629
2630   if [[ $cur == -* ]]; then
2631         if [[ $prev == llstream ]]; then
2632       COMPREPLY=($(compgen -W "$opts" -- $cur))
2633         else
2634       COMPREPLY=($(compgen -W "$lopts" -- $cur))
2635         fi
2636   elif [[ $prev == -in ]]; then
2637         COMPREPLY=($(compgen -W "$(_projects $cur)"))
2638   elif [[ $prev == -invob ]]; then
2639     COMPREPLY=($(compgen -W "$(_vobs $cur)"))
2640   elif [[ $prev == -view ]]; then
2641     COMPREPLY=($(compgen -W "$(lsviews)"))
2642   elif [[ $cur == * ]]; then
2643     COMPREPLY=($(compgen -W "$(_streams $cur)"))
2644   fi
2645 } # _lsstream
2646
2647 function _lstype () {
2648   local cur prev
2649   local opts="\
2650 $_global_opts \
2651 -fmt \
2652 -graphical \
2653 -invob \
2654 -kind \
2655 -local \
2656 -long \
2657 -nostatus \
2658 -obsolete \
2659 -short \
2660 -unsorted \
2661 "
2662   COMPREPLY=()
2663   cur="${COMP_WORDS[COMP_CWORD]}"
2664   prev="${COMP_WORDS[COMP_CWORD-1]}"
2665
2666   if [[ $cur == -* ]]; then
2667     COMPREPLY=($(compgen -W "$opts" -- $cur))
2668   elif [[ $prev == -kind ]]; then
2669         COMPREPLY=($(compgen -W "$_kinds" -- $cur))
2670   elif [[ $prev == -invob ]]; then
2671     COMPREPLY=($(compgen -W "$(_vobs $cur)"))
2672   elif [[ $cur == * ]]; then
2673     _type_selector
2674   fi
2675 } # _lstype
2676
2677 function _lsview () {
2678   local cur prev
2679   local opts="\
2680 $_global_opts \
2681 -age \
2682 -cview \
2683 -full \
2684 -host \
2685 -properties \
2686 -quick \
2687 -region \
2688 -short \
2689 -storage \
2690 -text \
2691 -uuid \
2692 "
2693   local lopts="$opts -long"
2694   
2695   COMPREPLY=()
2696   cur="${COMP_WORDS[COMP_CWORD]}"
2697   prev="${COMP_WORDS[COMP_CWORD-1]}"
2698
2699   if [[ $cur == -* ]]; then
2700         if [[ $prev == llview ]]; then
2701       COMPREPLY=($(compgen -W "$opts" -- $cur))
2702         else
2703       COMPREPLY=($(compgen -W "$lopts" -- $cur))
2704         fi
2705   elif [[ $prev == -region ]]; then
2706         COMPREPLY=($(compgen -W "$(_regions $cur)" -- $cur))
2707   elif [[ $prev == -host ]]; then
2708     COMPREPLY=($(compgen -W "$(_cchosts $cur)"))
2709   elif [[ $cur == * ]]; then
2710     COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
2711   fi
2712 } # _lsview
2713
2714 function _lsvob () {
2715   local cur prev
2716   local opts="\
2717 $_global_opts \
2718 -family \
2719 -graphical \
2720 -host \
2721 -quick \
2722 -region \
2723 -short \
2724 -storage \
2725 -uuid \
2726 "
2727   lopts="$opts -long"
2728   COMPREPLY=()
2729   cur="${COMP_WORDS[COMP_CWORD]}"
2730   prev="${COMP_WORDS[COMP_CWORD-1]}"
2731
2732   if [[ $cur == -* ]]; then
2733     if [[ $prev == llvob ]]; then
2734       COMPREPLY=($(compgen -W "$opts" -- $cur))
2735     else
2736       COMPREPLY=($(compgen -W "$lopts" -- $cur))
2737     fi      
2738   elif [[ $prev == -region ]]; then
2739         COMPREPLY=($(compgen -W "$(_regions $cur)"))
2740   elif [[ $prev == -host ]]; then
2741     COMPREPLY=($(compgen -W "$(_cchosts $cur)"))
2742   elif [[ $cur == * ]]; then
2743     COMPREPLY=($(compgen -W "$(_vobs $cur)"))
2744   fi
2745 } # _lsvob
2746
2747 function _mkactivity () {
2748   local cur prev
2749   local opts="\
2750 $_global_opts \
2751 -force \
2752 -headline \
2753 -in \
2754 -nset \
2755 "
2756   COMPREPLY=()
2757   cur="${COMP_WORDS[COMP_CWORD]}"
2758   prev="${COMP_WORDS[COMP_CWORD-1]}"
2759
2760   if [[ $cur == -* ]]; then
2761     COMPREPLY=($(compgen -W "$opts" -- $cur))
2762   elif [[ $prev == -in ]]; then
2763         COMPREPLY=($(compgen -W "$(_streams $cur)"))
2764   fi
2765 } # _mkactivity
2766
2767 function _mkbl () {
2768   local cur prev
2769   local opts="\
2770 $_global_opts \
2771 -activities \
2772 -adepends \
2773 -all \
2774 -component \
2775 -ddepends \
2776 -full \
2777 -identical \
2778 -import \
2779 -incremental \
2780 -nact \
2781 -nlabel \
2782 -view \
2783 "
2784   COMPREPLY=()
2785   cur="${COMP_WORDS[COMP_CWORD]}"
2786   prev="${COMP_WORDS[COMP_CWORD-1]}"
2787
2788   if [[ $cur == -* ]]; then
2789     COMPREPLY=($(compgen -W "$opts" -- $cur))
2790   elif [[ $prev == -activities ]]; then
2791         COMPREPLY=($(compgen -W "$(_activities $cur)"))
2792   elif [[ $prev == -component   ||
2793           $prev == -adepends_on ||
2794           $prev == -ddepends_on ]]; then
2795         COMPREPLY=($(compgen -W "$(_components $cur)"))
2796   elif [[ $prev == -clone ]]; then
2797         COMPREPLY=($(compgen -W "$(_baselines $cur)"))
2798   elif [[ $prev == -view ]]; then
2799         COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
2800   fi
2801 } # _mkbl
2802
2803 function _mkcomp () {
2804   local cur prev
2805   local opts="\
2806 $_global_opts \
2807 -nroot \
2808 -root \
2809 "
2810   COMPREPLY=()
2811   cur="${COMP_WORDS[COMP_CWORD]}"
2812   prev="${COMP_WORDS[COMP_CWORD-1]}"
2813
2814   if [[ $cur == -* ]]; then
2815     COMPREPLY=($(compgen -W "$opts" -- $cur))
2816   elif [[ $cur == * ]]; then
2817         COMPREPLY=($(compgen -W "$(_components $cur)"))
2818   fi
2819 } # _mkcomp
2820
2821 function _mkfolder () {
2822   local cur prev
2823   local opts="\
2824 $_global_opts \
2825 -in \
2826 "
2827   COMPREPLY=()
2828   cur="${COMP_WORDS[COMP_CWORD]}"
2829   prev="${COMP_WORDS[COMP_CWORD-1]}"
2830
2831   if [[ $cur == -* ]]; then
2832     COMPREPLY=($(compgen -W "$opts" -- $cur))
2833   elif [[ $prev == -in || 
2834           $cur  == * ]]; then
2835         COMPREPLY=($(compgen -W "$(_folders $cur)"))
2836   fi
2837 } # _mkfolder
2838
2839 function _mkproject () {
2840   local cur prev
2841   local opts="\
2842 $_global_opts \
2843 -blname \
2844 -connection \
2845 -crmenable \
2846 -custom \
2847 -in \
2848 -modcomp \
2849 -model \
2850 -npolicy \
2851 -policy \
2852 -spolicy \
2853 -template \
2854 "
2855   COMPREPLY=()
2856   cur="${COMP_WORDS[COMP_CWORD]}"
2857   prev="${COMP_WORDS[COMP_CWORD-1]}"
2858
2859   if [[ $cur == -* ]]; then
2860     COMPREPLY=($(compgen -W "$opts" -- $cur))
2861   elif [[ $prev == -modcomp ]]; then
2862         COMPREPLY=($(compgen -W "$(_components $cur)"))
2863   elif [[ $prev == -in ]]; then
2864         COMPREPLY=($(compgen -W "$(_folders $cur)"))
2865   elif [[ $prev == -policy  ||
2866           $prev == -npolicy ||
2867           $prev == -spolicy ]]; then
2868         COMPREPLY=($(compgen -W "$_policies" -- $cur))
2869   fi
2870 } # _mkproject
2871
2872 function _mkregion () {
2873   local cur prev
2874   local opts="\
2875 $_global_opts \
2876 -replace \
2877 -tag \
2878 -tcomment \
2879 "
2880   COMPREPLY=()
2881   cur="${COMP_WORDS[COMP_CWORD]}"
2882   prev="${COMP_WORDS[COMP_CWORD-1]}"
2883
2884   if [[ $cur == -* ]]; then
2885     COMPREPLY=($(compgen -W "$opts" -- $cur))
2886   elif [[ $prev == -tag ]]; then
2887         COMPREPLY=($(compgen -W "$(_regions $cur)" -- $cur))
2888   fi
2889 } # _mkregion
2890
2891 function _mkstgloc () {
2892   local cur prev
2893   local opts="\
2894 $_global_opts \
2895 -comment \
2896 -force \
2897 -gpath \
2898 -host \
2899 -hpath \
2900 -ngpath \
2901 -region \
2902 -view \
2903 -vob \
2904 "
2905   COMPREPLY=()
2906   cur="${COMP_WORDS[COMP_CWORD]}"
2907   prev="${COMP_WORDS[COMP_CWORD-1]}"
2908
2909   if [[ $cur == -* ]]; then
2910     COMPREPLY=($(compgen -W "$opts" -- $cur))
2911   elif [[ $prev == -region ]]; then
2912         COMPREPLY=($(compgen -W "$(_regions $cur)" -- $cur))
2913   elif [[ $prev == -host ]]; then
2914         COMPREPLY=($(compgen -W "$(_cchosts $cur)"))
2915   fi
2916 } # _mkstgloc
2917
2918 function _mkstream () {
2919   local cur prev
2920   local opts="\
2921 $_global_opts \
2922 -amodcomp \
2923 -baseline \
2924 -in \
2925 -integration \
2926 -nc \
2927 -npolicy \
2928 -policy \
2929 -readonly \
2930 -target \
2931 -template \
2932 "
2933   COMPREPLY=()
2934   cur="${COMP_WORDS[COMP_CWORD]}"
2935   prev="${COMP_WORDS[COMP_CWORD-1]}"
2936
2937   if [[ $cur == -* ]]; then
2938     COMPREPLY=($(compgen -W "$opts" -- $cur))
2939   elif [[ $prev == -amodcomp ]]; then
2940         COMPREPLY=($(compgen -W "$(_components $cur)"))
2941   elif [[ $prev == -baseline ]]; then
2942         COMPREPLY=($(compgen -W "$(_baselines $cur)"))
2943   elif [[ $prev == -in ]]; then
2944         COMPREPLY=($(compgen -W "$(_projects $cur)"))
2945   elif [[ $prev == -policy  ||
2946           $prev == -npolicy ]]; then
2947         COMPREPLY=($(compgen -W "$(_policies $cur)" -- $cur))
2948   fi
2949 } # _mkstream
2950
2951 function _mktag () {
2952   local cur prev
2953   local opts="\
2954 $_global_opts \
2955 -gpath \
2956 -host \
2957 -nstart \
2958 -options \
2959 -password \
2960 -public \
2961 -region \
2962 -replace \
2963 -tag \
2964 -tcomment \
2965 -view \
2966 -vob \
2967 "
2968   COMPREPLY=()
2969   cur="${COMP_WORDS[COMP_CWORD]}"
2970   prev="${COMP_WORDS[COMP_CWORD-1]}"
2971   prev2="$(COMP_WORDS[COMP_CWORD-2])"
2972
2973   if [[ $cur == -* ]]; then
2974     COMPREPLY=($(compgen -W "$opts" -- $cur))
2975   elif [[ $prev2 == -view && $prev == "-tag" ]]; then
2976         COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
2977   elif [[ $prev2 == -vob && $prev == "-tag" ]]; then
2978         COMPREPLY=($(compgen -W "$(_vobs $cur)"))
2979   elif [[ $prev == -region ]]; then
2980         COMPREPLY=($(compgen -W "$(_regions $cur)" -- $cur))
2981   elif [[ $prev == -host ]]; then
2982         COMPREPLY=($(compgen -W "$(_cchosts $cur)"))
2983   fi
2984 } # _mktag
2985
2986 function _mktrtype () {
2987   local cur prev
2988   local opts="\
2989 $_global_opts \
2990 -activity \
2991 -all \
2992 -attype \
2993 -baseline \
2994 -brtype \
2995 -component \
2996 -eltype \
2997 -execunix \
2998 -execwin \
2999 -folder \
3000 -hltype \
3001 -lbtype \
3002 -mkattr \
3003 -mkhlink \
3004 -mklabel \
3005 -nc \
3006 -nusers \
3007 -postop \
3008 -print \
3009 -project \
3010 -replace \
3011 -stream \
3012 -trtype \
3013 -type \
3014 -ucmobject \
3015 "
3016   COMPREPLY=()
3017   cur="${COMP_WORDS[COMP_CWORD]}"
3018   prev="${COMP_WORDS[COMP_CWORD-1]}"
3019
3020   if [[ $cur == -* ]]; then
3021     COMPREPLY=($(compgen -W "$opts" -- $cur))
3022   elif [[ $prev == -preop ||
3023           $prev == -postopt ]]; then
3024         COMPREPLY=($(compgen -W "$_operation_types" -- $cur))
3025   elif [[ $prev == -project ]]; then
3026         COMPREPLY=($(compgen -W "$(_projects $cur)"))
3027   elif [[ $prev == -stream ]]; then
3028         COMPREPLY=($(compgen -W "$(_streams $cur)"))
3029   elif [[ $prev == -component ]]; then
3030         COMPREPLY=($(compgen -W "$(_components $cur)"))
3031   elif [[ $prev == -folder ]]; then
3032         COMPREPLY=($(compgen -W "$(_folders $cur)"))
3033   elif [[ $prev == -activity ]]; then
3034         COMPREPLY=($(compgen -W "$(_activites $cur)" -- $cur))
3035   elif [[ $prev == -baseline ]]; then
3036         COMPREPLY=($(compgen -W "$(_baselines $cur)"))
3037   elif [[ $prev == -attype ]]; then
3038         COMPREPLY=($(compgen -W "$(_attypes $cur)"))
3039   elif [[ $prev == -brtype ]]; then
3040         COMPREPLY=($(compgen -W "$(_brtypes $cur)"))
3041   elif [[ $prev == -eltype ]]; then
3042         COMPREPLY=($(compgen -W "$(_eltypes $cur)"))
3043   elif [[ $prev == -hltype ]]; then
3044         COMPREPLY=($(compgen -W "$(_hltypes $cur)"))
3045   elif [[ $prev == -lbtype ]]; then
3046         COMPREPLY=($(compgen -W "$(_lbtypes $cur)"))
3047   elif [[ $prev == -trtypes ]]; then
3048         COMPREPLY=($(compgen -W "$(_trtypes $cur)"))
3049   fi
3050 } # _mktrtype
3051
3052 function _mkview () {
3053   local cur prev
3054   local opts="\
3055 $_global_opts \
3056 -auto \
3057 -cachesize \
3058 -colocated \
3059 -gpath \
3060 -host \
3061 -hpath \
3062 -nshareable \
3063 -ptime \
3064 -region \
3065 -shareable \
3066 -snapshot \
3067 -stgloc \
3068 -stream \
3069 -tag \
3070 -tcomment \
3071 -tmode \
3072 -vws \
3073 "
3074   COMPREPLY=()
3075   cur="${COMP_WORDS[COMP_CWORD]}"
3076   prev="${COMP_WORDS[COMP_CWORD-1]}"
3077
3078   if [[ $cur == -* ]]; then
3079     COMPREPLY=($(compgen -W "$opts" -- $cur))
3080   elif [[ $prev == -tag ]]; then
3081         COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
3082   elif [[ $prev == -region ]]; then
3083         COMPREPLY=($(compgen -W "$(_regions $cur)" -- $cur))
3084   elif [[ $prev == -stgloc ]]; then
3085         COMPREPLY=($(compgen -W "$(_stglocs $cur)"))
3086   elif [[ $prev == -host ]]; then
3087         COMPREPLY=($(compgen -W "$(_cchosts $cur)"))
3088   fi
3089 } # _mkview
3090
3091 function _mkvob () {
3092   local cur prev
3093   local opts="\
3094 $_global_opts \
3095 -auto \
3096 -gpath \
3097 -host \
3098 -hpath \
3099 -nc \
3100 -nremote \
3101 -options \
3102 -password \
3103 -public \
3104 -region \
3105 -stgloc \
3106 -tag \
3107 -tcomment \
3108 -ucmproject \
3109 "
3110   COMPREPLY=()
3111   cur="${COMP_WORDS[COMP_CWORD]}"
3112   prev="${COMP_WORDS[COMP_CWORD-1]}"
3113
3114   if [[ $cur == -* ]]; then
3115     COMPREPLY=($(compgen -W "$opts" -- $cur))
3116   elif [[ $prev == -tag ]]; then
3117         COMPREPLY=($(compgen -W "$(_vobs $cur)"))
3118   elif [[ $prev == -region ]]; then
3119         COMPREPLY=($(compgen -W "$(_regions $cur)" -- $cur))
3120   elif [[ $prev == -stgloc ]]; then
3121         COMPREPLY=($(compgen -W "$(_stglocs $cur)"))
3122   elif [[ $prev == -host ]]; then
3123         COMPREPLY=($(compgen -W "$(_cchosts $cur)"))
3124   fi
3125 } # _mkvob
3126
3127 function _mount () {
3128   local cur prev
3129   local opts="\
3130 $_global_opts \
3131 -all \
3132 -options \
3133 -persistent \
3134 "
3135   COMPREPLY=()
3136   cur="${COMP_WORDS[COMP_CWORD]}"
3137   prev="${COMP_WORDS[COMP_CWORD-1]}"
3138
3139   if [[ $cur == -* ]]; then
3140     COMPREPLY=($(compgen -W "$opts" -- $cur))
3141   elif [[ $cur == * ]]; then
3142         COMPREPLY=($(compgen -W "$(_vobs $cur)"))
3143   fi
3144 } # _mount
3145
3146 function _rebase () {
3147   local cur prev
3148   local opts="\
3149 $_global_opts \
3150 -abort \
3151 -baseline \
3152 -cancel \
3153 -complete \
3154 -dbaseline \
3155 -force \
3156 -gmerge \
3157 -graphical \
3158 -long \
3159 -ok \
3160 -preview \
3161 -qall \
3162 -qntrivial \
3163 -query \
3164 -recommended \
3165 -resume \
3166 -serial \
3167 -short \
3168 -status \
3169 -stream \
3170 -view \
3171 "
3172   COMPREPLY=()
3173   cur="${COMP_WORDS[COMP_CWORD]}"
3174   prev="${COMP_WORDS[COMP_CWORD-1]}"
3175
3176   if [[ $cur == -* ]]; then
3177     COMPREPLY=($(compgen -W "$opts" -- $cur))
3178   elif [[ $prev == -view ]]; then
3179         COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
3180   elif [[ $prev == -stream ]]; then
3181         COMPREPLY=($(compgen -W "$(_streams $cur)"))
3182   elif [[ $prev == -baseline  ||
3183           $prev == -dbaseline ]]; then
3184         COMPREPLY=($(compgen -W "$(_baselines $cur)"))
3185   fi
3186 } # _rebase
3187
3188 function _recoverview () {
3189   local cur prev
3190   local opts="\
3191 $_global_opts \
3192 -directory \
3193 -force \
3194 _synchronize \
3195 -tag \
3196 -vob \
3197 "
3198   COMPREPLY=()
3199   cur="${COMP_WORDS[COMP_CWORD]}"
3200   prev="${COMP_WORDS[COMP_CWORD-1]}"
3201
3202   if [[ $cur == -* ]]; then
3203     COMPREPLY=($(compgen -W "$opts" -- $cur))
3204   elif [[ $prev == -tag ]]; then
3205         COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
3206   elif [[ $prev == -vob ]]; then
3207         COMPREPLY=($(compgen -W "$(_vobs $cur)"))
3208   fi
3209 } # _recoverview
3210
3211 function _reformatview () {
3212   local cur prev
3213   local opts="\
3214 $_global_opts \
3215 -dump \
3216 -load \
3217 -tag \
3218 "
3219   COMPREPLY=()
3220   cur="${COMP_WORDS[COMP_CWORD]}"
3221   prev="${COMP_WORDS[COMP_CWORD-1]}"
3222
3223   if [[ $cur == -* ]]; then
3224     COMPREPLY=($(compgen -W "$opts" -- $cur))
3225   elif [[ $prev == -tag ]]; then
3226         COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
3227   fi
3228 } # _reformatview
3229
3230 function _reformatvob () {
3231   local cur prev
3232   local opts="\
3233 $_global_opts \
3234 -dump \
3235 -force \
3236 -host \
3237 -hpath \
3238 -load \
3239 -rm \
3240 "
3241   COMPREPLY=()
3242   cur="${COMP_WORDS[COMP_CWORD]}"
3243   prev="${COMP_WORDS[COMP_CWORD-1]}"
3244
3245   if [[ $cur == -* ]]; then
3246     COMPREPLY=($(compgen -W "$opts" -- $cur))
3247   elif [[ $prev == -host ]]; then
3248         COMPREPLY=($(compgen -W "$(_cchosts $cur)"))
3249   fi
3250 } # _reformatvob
3251
3252 function _register () {
3253   local cur prev
3254   local opts="\
3255 $_global_opts \
3256 -host \
3257 -hpath \
3258 -replace \
3259 -ucmproject \
3260 -view \
3261 -vob \
3262 "
3263   COMPREPLY=()
3264   cur="${COMP_WORDS[COMP_CWORD]}"
3265   prev="${COMP_WORDS[COMP_CWORD-1]}"
3266
3267   if [[ $cur == -* ]]; then
3268     COMPREPLY=($(compgen -W "$opts" -- $cur))
3269   elif [[ $prev == -host ]]; then
3270         COMPREPLY=($(compgen -W "$(_cchosts $cur)"))
3271   fi
3272 } # _register
3273
3274 function _rmactivity () {
3275   local cur prev
3276   local opts="\
3277 $_global_opts \
3278 $_comment_opts \
3279 -force \
3280 "
3281   COMPREPLY=()
3282   cur="${COMP_WORDS[COMP_CWORD]}"
3283   prev="${COMP_WORDS[COMP_CWORD-1]}"
3284
3285   if [[ $cur == -* ]]; then
3286     COMPREPLY=($(compgen -W "$opts" -- $cur))
3287   elif [[ $cur == * ]]; then
3288         COMPREPLY=($(compgen -W "$(_activities $cur)"))
3289   fi
3290 } # _rmactivity
3291
3292 function _rmattr () {
3293   local cur prev
3294   local opts="\
3295 $_global_opts \
3296 $_comment_opts \
3297 -recurse \
3298 -version \
3299 "
3300   COMPREPLY=()
3301   cur="${COMP_WORDS[COMP_CWORD]}"
3302   prev="${COMP_WORDS[COMP_CWORD-1]}"
3303
3304   if [[ $cur == -* ]]; then
3305     COMPREPLY=($(compgen -W "$opts" -- $cur))
3306   elif [[ $cur == * ]]; then
3307         COMPREPLY=($(compgen -W "$(_attypes $cur)"))
3308   fi
3309 } # _rmattr
3310
3311 function _rmbl () {
3312   local cur prev
3313   local opts="\
3314 $_global_opts \
3315 $_comment_opts \
3316 -force\
3317 "
3318   COMPREPLY=()
3319   cur="${COMP_WORDS[COMP_CWORD]}"
3320   prev="${COMP_WORDS[COMP_CWORD-1]}"
3321
3322   if [[ $cur == -* ]]; then
3323     COMPREPLY=($(compgen -W "$opts" -- $cur))
3324   elif [[ $cur == * ]]; then
3325         COMPREPLY=($(compgen -W "$(_baselines $cur)"))
3326   fi
3327 } # _rmbl
3328
3329 function _rmcomp () {
3330   local cur prev
3331   local opts="\
3332 $_global_opts \
3333 $_comment_opts \
3334 -force\
3335 "
3336   COMPREPLY=()
3337   cur="${COMP_WORDS[COMP_CWORD]}"
3338   prev="${COMP_WORDS[COMP_CWORD-1]}"
3339
3340   if [[ $cur == -* ]]; then
3341     COMPREPLY=($(compgen -W "$opts" -- $cur))
3342   elif [[ $cur == * ]]; then
3343         COMPREPLY=($(compgen -W "$(_components $cur)"))
3344   fi
3345 } # _rmcomp
3346
3347 function _rmfolder () {
3348   local cur prev
3349   local opts="\
3350 $_global_opts \
3351 $_comment_opts \
3352 -force\
3353 "
3354   COMPREPLY=()
3355   cur="${COMP_WORDS[COMP_CWORD]}"
3356   prev="${COMP_WORDS[COMP_CWORD-1]}"
3357
3358   if [[ $cur == -* ]]; then
3359     COMPREPLY=($(compgen -W "$opts" -- $cur))
3360   elif [[ $cur == * ]]; then
3361         COMPREPLY=($(compgen -W "$(_folders $cur)"))
3362   fi
3363 } # _rmfolder
3364
3365 function _rmhlink () {
3366   local cur prev
3367   local opts="\
3368 $_global_opts \
3369 $_comment_opts \
3370 "
3371   COMPREPLY=()
3372   cur="${COMP_WORDS[COMP_CWORD]}"
3373   prev="${COMP_WORDS[COMP_CWORD-1]}"
3374
3375   if [[ $cur == -* ]]; then
3376     COMPREPLY=($(compgen -W "$opts" -- $cur))
3377   elif [[ $cur == * ]]; then
3378         COMPREPLY=($(compgen -W "$(_hltypes $cur)"))
3379   fi
3380 } # _rmhlink
3381
3382 function _rmlabel () {
3383   local cur prev
3384   local opts="\
3385 $_global_opts \
3386 $_comment_opts \
3387 -follow \
3388 -recurse \
3389 -version \
3390 "
3391   COMPREPLY=()
3392   cur="${COMP_WORDS[COMP_CWORD]}"
3393   prev="${COMP_WORDS[COMP_CWORD-1]}"
3394
3395   if [[ $cur == -* ]]; then
3396     COMPREPLY=($(compgen -W "$opts" -- $cur))
3397   elif [[ $cur == * ]]; then
3398         COMPREPLY=($(compgen -W "$(_lbtypes $cur)"))
3399   fi
3400 } # _rmlabel
3401
3402 function _rmproject () {
3403   local cur prev
3404   local opts="\
3405 $_global_opts \
3406 $_comment_opts \
3407 -force \
3408 -template \
3409 "
3410   COMPREPLY=()
3411   cur="${COMP_WORDS[COMP_CWORD]}"
3412   prev="${COMP_WORDS[COMP_CWORD-1]}"
3413
3414   if [[ $cur == -* ]]; then
3415     COMPREPLY=($(compgen -W "$opts" -- $cur))
3416   elif [[ $cur == * ]]; then
3417         COMPREPLY=($(compgen -W "$(_projects $cur)"))
3418   fi
3419 } # _rmproject
3420
3421 function _rmregion () {
3422   local cur prev
3423   local opts="\
3424 $_global_opts \
3425 -password \
3426 -rmall \
3427 -tag \
3428 "
3429   COMPREPLY=()
3430   cur="${COMP_WORDS[COMP_CWORD]}"
3431   prev="${COMP_WORDS[COMP_CWORD-1]}"
3432
3433   if [[ $cur == -* ]]; then
3434     COMPREPLY=($(compgen -W "$opts" -- $cur))
3435   elif [[ $prev == -tag ]]; then
3436         COMPREPLY=($(compgen -W "$(_regions $cur)" -- $cur))
3437   fi
3438 } # _rmregion
3439
3440 function _rmstgloc () {
3441   local cur prev
3442   local opts="\
3443 $_global_opts \
3444 -all \
3445 -region \
3446 -storage \
3447 "
3448   COMPREPLY=()
3449   cur="${COMP_WORDS[COMP_CWORD]}"
3450   prev="${COMP_WORDS[COMP_CWORD-1]}"
3451
3452   if [[ $cur == -* ]]; then
3453     COMPREPLY=($(compgen -W "$opts" -- $cur))
3454   elif [[ $prev == -region ]]; then
3455         COMPREPLY=($(compgen -W "$(_regions $cur)" -- $cur))
3456   elif [[ $cur == * ]]; then
3457         COMPREPLY=($(compgen -W "$(_stglocs $cur)"))
3458   fi
3459 } # _rmstgloc
3460
3461 function _rmstream () {
3462   local cur prev
3463   local opts="\
3464 $_global_opts \
3465 $_comment_opts \
3466 -force \
3467 -template \
3468 "
3469   COMPREPLY=()
3470   cur="${COMP_WORDS[COMP_CWORD]}"
3471   prev="${COMP_WORDS[COMP_CWORD-1]}"
3472
3473   if [[ $cur == -* ]]; then
3474     COMPREPLY=($(compgen -W "$opts" -- $cur))
3475   elif [[ $cur == * ]]; then
3476         COMPREPLY=($(compgen -W "$(_streams $cur)"))
3477   fi
3478 } # _rmstream
3479
3480 function _rmtag () {
3481   local cur prev
3482   local opts="\
3483 $_global_opts \
3484 -all \
3485 -region \
3486 -view \
3487 -vob \
3488 -password \
3489 "
3490   COMPREPLY=()
3491   cur="${COMP_WORDS[COMP_CWORD]}"
3492   prev="${COMP_WORDS[COMP_CWORD-1]}"
3493
3494   if [[ $cur == -* ]]; then
3495     COMPREPLY=($(compgen -W "$opts" -- $cur))
3496   elif [[ $prev == -view ]]; then
3497         COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))
3498   elif [[ $prev == -vob ]]; then
3499         COMPREPLY=($(compgen -W "$(_vobs $cur)"))
3500   elif [[ $prev == -region ]]; then
3501         COMPREPLY=($(compgen -W "$(_regions $cur)" -- $cur))
3502   fi
3503 } # _rmtag
3504
3505 function _rmtrigger () {
3506   local cur prev
3507   local opts="\
3508 $_global_opts \
3509 $_comment_opts \
3510 -nattach \
3511 -ninherit \
3512 -recurse \
3513 "
3514   COMPREPLY=()
3515   cur="${COMP_WORDS[COMP_CWORD]}"
3516   prev="${COMP_WORDS[COMP_CWORD-1]}"
3517
3518   if [[ $cur == -* ]]; then
3519     COMPREPLY=($(compgen -W "$opts" -- $cur))
3520   elif [[ $cur == * ]]; then
3521         COMPREPLY=($(compgen -W "$(_trtypes $cur)"))
3522   fi
3523 } # _rmtrigger
3524
3525 function _rmtype () {
3526   local cur prev
3527   local opts="\
3528 $_global_opts \
3529 $_comment_opts \
3530 -force \
3531 -ignore \
3532 -rmall \
3533 "
3534   COMPREPLY=()
3535   cur="${COMP_WORDS[COMP_CWORD]}"
3536   prev="${COMP_WORDS[COMP_CWORD-1]}"
3537
3538   if [[ $cur == -* ]]; then
3539     COMPREPLY=($(compgen -W "$opts" -- $cur))
3540   elif [[ $cur == * ]]; then
3541         _type_selectors
3542   fi
3543 } # _rmtype
3544
3545 function _rmview () {
3546   local cur prev
3547   local opts="\
3548 $_global_opts \
3549 $_comment_opts \
3550 -all \
3551 -avobs \
3552 -force \
3553 -tag \
3554 -vob \
3555 "
3556   COMPREPLY=()
3557   cur="${COMP_WORDS[COMP_CWORD]}"
3558   prev="${COMP_WORDS[COMP_CWORD-1]}"
3559
3560   if [[ $cur == -* ]]; then
3561     COMPREPLY=($(compgen -W "$opts" -- $cur))
3562   elif [[ $prev == -tag ]]; then
3563         COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))          
3564   elif [[ $prev == -vob ]]; then
3565         COMPREPLY=($(compgen -W "$(_vobs $cur)"))       
3566   fi
3567 } # _rmview
3568
3569 function _rmvob () {
3570   local cur prev
3571   local opts="\
3572 $_global_opts \
3573 -force \
3574 "
3575   COMPREPLY=()
3576   cur="${COMP_WORDS[COMP_CWORD]}"
3577   prev="${COMP_WORDS[COMP_CWORD-1]}"
3578
3579   if [[ $cur == -* ]]; then
3580     COMPREPLY=($(compgen -W "$opts" -- $cur))
3581   elif [[ $cur == * ]]; then
3582         COMPREPLY=($(compgen -W "$(_vobs $cur)"))       
3583   fi
3584 } # _rmvob
3585
3586 function _setcs () {
3587   local cur prev
3588   local opts="\
3589 $_global_opts \
3590 -ctime \
3591 -current \
3592 -default \
3593 -force \
3594 -overwrite \
3595 -pname \
3596 -ptime \
3597 -rename \
3598 -stream \
3599 -tag \
3600 "
3601   COMPREPLY=()
3602   cur="${COMP_WORDS[COMP_CWORD]}"
3603   prev="${COMP_WORDS[COMP_CWORD-1]}"
3604
3605   if [[ $cur == -* ]]; then
3606     COMPREPLY=($(compgen -W "$opts" -- $cur))
3607   elif [[ $cur == -tag ]]; then
3608         COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))          
3609   fi
3610 } # _setcs
3611
3612 function _setplevel () {
3613   local cur prev
3614   local opts="\
3615 $_global_opts \
3616 $_comment_opts \
3617 -default \
3618 -invob \
3619 "
3620   COMPREPLY=()
3621   cur="${COMP_WORDS[COMP_CWORD]}"
3622   prev="${COMP_WORDS[COMP_CWORD-1]}"
3623
3624   if [[ $cur == -* ]]; then
3625     COMPREPLY=($(compgen -W "$opts" -- $cur))
3626   elif [[ $prev == -invob ]]; then
3627         COMPREPLY=($(compgen -W "$(_vobs $cur)"))       
3628   fi
3629 } # _setplevel
3630
3631 function _setview() {
3632   local cur prev
3633   local opts="\
3634 $_global_opts \
3635 -login \
3636 -exec \
3637 "
3638   COMPREPLY=()
3639   cur="${COMP_WORDS[COMP_CWORD]}"
3640   prev="${COMP_WORDS[COMP_CWORD-1]}"
3641
3642   if [[ $cur == -* && $ARCHITECTURE != cygwin ]]; then
3643     COMPREPLY=($(compgen -W "$opts" -- $cur))
3644   elif [[ $cur == * ]]; then
3645         COMPREPLY=($(compgen -W "$(_views $cur)"))      
3646   fi
3647 } # _setview
3648
3649 function _space () {
3650   local cur prev
3651   local opts="\
3652 $_global_opts \
3653 -all \
3654 -directory \
3655 -generate \
3656 -host \
3657 -region \
3658 -scrub \
3659 -update \
3660 -view \
3661 -vob \
3662 "
3663   COMPREPLY=()
3664   cur="${COMP_WORDS[COMP_CWORD]}"
3665   prev="${COMP_WORDS[COMP_CWORD-1]}"
3666
3667   if [[ $cur == -* ]]; then
3668     COMPREPLY=($(compgen -W "$opts" -- $cur))
3669   elif [[ $prev == -view ]]; then
3670         COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))          
3671   elif [[ $prev == -vob || $cur == * ]]; then
3672         COMPREPLY=($(compgen -W "$(_vobs $cur)"))       
3673   fi
3674 } # _space
3675
3676 function _startview () {
3677   local cur prev
3678   local opts="\
3679 $_global_opts \
3680 "
3681   COMPREPLY=()
3682   cur="${COMP_WORDS[COMP_CWORD]}"
3683   prev="${COMP_WORDS[COMP_CWORD-1]}"
3684
3685   if [[ $cur == -* ]]; then
3686     COMPREPLY=($(compgen -W "$opts" -- $cur))
3687   elif [[ $cur == * ]]; then
3688         COMPREPLY=($(compgen -W "$(lsviews)" -- $cur))          
3689   fi
3690 } # _startview
3691
3692 function _umount () {
3693   local cur prev
3694   local opts="\
3695 $_global_opts \
3696 -all
3697 "
3698   COMPREPLY=()
3699   cur="${COMP_WORDS[COMP_CWORD]}"
3700   prev="${COMP_WORDS[COMP_CWORD-1]}"
3701
3702   if [[ $cur == -* ]]; then
3703     COMPREPLY=($(compgen -W "$opts" -- $cur))
3704   elif [[ $cur == * ]]; then
3705         COMPREPLY=($(compgen -W "$(_vobs $cur)"))       
3706   fi
3707 } # _umount
3708
3709 function _unlock () {
3710   local cur prev
3711   local opts="\
3712 $_global_opts \
3713 $_comment_opts \
3714 -pname \
3715 -version \
3716 "
3717   COMPREPLY=()
3718   cur="${COMP_WORDS[COMP_CWORD]}"
3719   prev="${COMP_WORDS[COMP_CWORD-1]}"
3720
3721   if [[ $cur == -* ]]; then
3722     COMPREPLY=($(compgen -W "$opts" -- $cur))
3723   elif [[ $cur == * ]]; then
3724         COMPREPLY=($(compgen -W "$(_object_selector $cur)" -- $cur))    
3725   fi
3726 } # _unlock
3727
3728 function _scm () {
3729   local cur prev
3730
3731   COMPREPLY=()
3732   cur="${COMP_WORDS[COMP_CWORD]}"
3733   cmd="${COMP_WORDS[0]}"
3734   subcmd="${COMP_WORDS[1]}"
3735   
3736   if [[ $cmd == scm || $cmd == ct ]]; then
3737         if [[ $COMP_CWORD == 1 ]]; then
3738           COMPREPLY=($(compgen -W "$_scm_cmds" -- $cur))
3739         else
3740       case "$subcmd" in
3741         annotate)
3742           COMPREPLY=($(compgen -W "$_annotate_opts" -- $cur));;
3743         catcr)
3744           COMPREPLY=($(compgen -W "$_catcr_opts" -- $cur));;
3745         catcs)
3746           _catcs;;
3747         chactivity)
3748           _chactivity;;
3749         chbl)
3750           COMPREPLY=($(compgen -W "$_chbl_opts" -- $cur));;
3751         checkin|ci)
3752           _checkin;;
3753         checkout|co)
3754           COMPREPLY=($(compgen -W "$_checkout_opts" -- $cur));;
3755         checkvob)
3756           _checkvob;;
3757         chevent)
3758           _chevent;;
3759         chflevel)
3760           COMPREPLY=($(compgen -W "$_chflevel_opts" -- $cur));;
3761         chfolder)
3762           _chfolder;;
3763         chmaster)
3764           _chmaster;;
3765         chpool)
3766           COMPREPLY=($(compgen -W "$_chpool_opts" -- $cur));;
3767         chproject)
3768           _chproject;;
3769         chstream)
3770           _chstream;;
3771         chtype)
3772           COMPREPLY=($(compgen -W "$_chtype_opts" -- $cur));;
3773         chview)
3774           _chview;;
3775         deliver)
3776           _deliver;;
3777         describe|desc)
3778           _describe;;
3779         diff)
3780           COMPREPLY=($(compgen -W "$_diff_opts" -- $cur));;
3781         diffbl)
3782           COMPREPLY=($(compgen -W "$_diffbl_opts" -- $cur));;
3783         diffcr)
3784           COMPREPLY=($(compgen -W "$_diffcr_opts" -- $cur));;
3785         dospace)
3786           _dospace;;
3787         edcs)
3788           _edcs;;
3789         endview)
3790           _endview;;
3791         file)
3792           _file;;
3793         find)
3794           COMPREPLY=($(compgen -W "$_find_opts" -- $cur));;
3795         findmerge)
3796           COMPREPLY=($(compgen -W "$_findmerge_opts" -- $cur));;
3797         get)
3798           COMPREPLY=($(compgen -W "$_get_opts" -- $cur));;
3799         getcache)
3800           COMPREPLY=($(compgen -W "$_getcache_opts" -- $cur));;
3801         getlog)
3802           _getlog;;
3803         help)
3804           COMPREPLY=($(compgen -W "$_scm_cmds" -- $cur));;
3805         hostinfo)
3806           _hostinfo;;
3807         ln)
3808           COMPREPLY=($(compgen -W "$_ln_opts" -- $cur));;
3809         ls)
3810           COMPREPLY=($(compgen -W "$_ls_opts" -- $cur));;
3811         lsactivity)
3812           _lsactivity;;
3813         lsbl)
3814           _lsbl;;
3815         lscheckout|lsco)
3816           COMPREPLY=($(compgen -W "$_lscheckout_opts" -- $cur));;
3817         lsclients)
3818           lsclients;;
3819         lscomp)
3820           _lscomp;;
3821         lsdo)
3822           COMPREPLY=($(compgen -W "$_lsdo_opts" -- $cur));;
3823         lsfolder)
3824           _lsfolder;;
3825         lshistory)
3826           COMPREPLY=($(compgen -W "$_lshistory_opts" -- $cur));;
3827         lslock)
3828           COMPREPLY=($(compgen -W "$_lslock_opts" -- $cur));;
3829         lsmaster)
3830           COMPREPLY=($(compgen -W "$_lsmaster_opts" -- $cur));;
3831         lspool)
3832           _lspool;;
3833         lsprivate)
3834           _lsprivate;;
3835         lsproject)
3836           _lsproject;;
3837         lsregion)
3838           _lsregion;;
3839         lsreplica)
3840           COMPREPLY=($(compgen -W "$_lsreplica_opts" -- $cur));;
3841         lssite)
3842           COMPREPLY=($(compgen -W "$_lssite_opts" -- $cur));;
3843         lsstgloc)
3844           _lsstgloc;;
3845         lsstream)
3846           _lsstream;;
3847         lstype)
3848           _lstype;;
3849         lsview)
3850           _lsview;;
3851         lsvob)
3852           _lsvob;;
3853         lsvtree|vtree)
3854           COMPREPLY=($(compgen -W "$_lsvtree_opts" -- $cur));;
3855         man)
3856           COMPREPLY=($(compgen -W "$_scm_cmds" -- $cur));;
3857         merge)
3858           COMPREPLY=($(compgen -W "$_merge_opts" -- $cur));;
3859         mkactivity)
3860           _mkactivity;;
3861         mkattr)
3862           COMPREPLY=($(compgen -W "$_mkattr_opts" -- $cur));;
3863         mkattype)
3864           COMPREPLY=($(compgen -W "$_mkattype_opts" -- $cur));;          
3865         mkbl)
3866           _mkbl;;
3867         mkbranch)
3868           COMPREPLY=($(compgen -W "$_mkbranch_opts" -- $cur));;
3869         mkbrtype)
3870           COMPREPLY=($(compgen -W "$_mkbrtype_opts" -- $cur));;
3871         mkcomp)
3872           _mkcomp;;
3873         mkdir)
3874           COMPREPLY=($(compgen -W "$_mkdir_opts" -- $cur));;
3875         mkelem)
3876           COMPREPLY=($(compgen -W "$_mkelem_opts" -- $cur));;
3877         mkeltype)
3878           COMPREPLY=($(compgen -W "$_mkeltype_opts" -- $cur));;
3879         mkfolder)
3880           _mkfolder;;
3881         mkhlink)
3882           COMPREPLY=($(compgen -W "$_mkhlink_opts" -- $cur));;
3883         mkhltype)
3884           COMPREPLY=($(compgen -W "$_mkhltype_opts" -- $cur));;
3885         mklabel)
3886           COMPREPLY=($(compgen -W "$_mklabel_opts" -- $cur));;
3887         mklbtype)
3888           COMPREPLY=($(compgen -W "$_mklbtype_opts" -- $cur));;
3889         mkpool)
3890           COMPREPLY=($(compgen -W "$_mkpool_opts" -- $cur));;
3891         mkproject)
3892           _mkproject;;
3893         mkregion)
3894           _mkregion;;
3895         mkstgloc)
3896           _mkstgloc;;
3897         mkstream)
3898           _mkstream;;
3899         mktag)
3900           _mktag;;
3901         mktrigger)
3902           COMPREPLY=($(compgen -W "$_mktrigger_opts" -- $cur));;
3903         mktrtype)
3904           _mktrtype;;
3905         mkview)
3906           _mkview;;
3907         mkvob)
3908           _mkvob;;
3909         mount)
3910           _mount;;
3911         move)
3912           COMPREPLY=($(compgen -W "$_move_opts" -- $cur));;
3913         protect)
3914           COMPREPLY=($(compgen -W "$_protect_opts" -- $cur));;
3915         protectvob)
3916           COMPREPLY=($(compgen -W "$_protectvob_opts" -- $cur));;
3917         pwd)
3918           COMPREPLY=($(compgen -W "$_pwd_opts" -- $cur));;
3919         pwv)
3920           COMPREPLY=($(compgen -W "$_pwv_opts" -- $cur));;
3921         rebase)
3922           _rebase;;
3923         recoverview)
3924           _recoverview;;
3925         reformatview)
3926           _reformatview;;
3927         reformatvob)
3928           _reformatvob;;
3929         register)
3930           _register;;
3931         relocate)
3932           COMPREPLY=($(compgen -W "$_relocate_opts" -- $cur));;
3933         rename)
3934           COMPREPLY=($(compgen -W "$_rename_opts" -- $cur));;
3935         reqmaster)
3936           COMPREPLY=($(compgen -W "$_reqmaster_opts" -- $cur));;
3937         reserve)
3938           COMPREPLY=($(compgen -W "$_reserve_opts" -- $cur));;
3939         rmactivity)
3940           _rmactivity;;
3941         rmattr)
3942           _rmattr;;
3943         rmbl)
3944           _rmbl;;
3945         rmbranch)
3946           COMPREPLY=($(compgen -W "$_rmbranch_opts" -- $cur));;
3947         rmcomp)
3948           _rmcomp;;
3949         rmdo)
3950           COMPREPLY=($(compgen -W "$_rmdo_opts" -- $cur));;
3951         rmelem)
3952           COMPREPLY=($(compgen -W "$_rmelem_opts" -- $cur));;
3953         rmfolder)
3954           _rmfolder;;
3955         rmhlink)
3956           _rmhlink;;
3957         rmlabel)
3958           _rmlabel;;
3959         rmmerge)
3960           COMPREPLY=($(compgen -W "$_rmmerge_opts" -- $cur));;
3961         rmname)
3962           COMPREPLY=($(compgen -W "$_rmname_opts" -- $cur));;
3963         rmpool)
3964           COMPREPLY=($(compgen -W "$_rmpool_opts" -- $cur));;
3965         rmproject)
3966           _rmproject;;
3967         rmregion)
3968           _rmregion;;
3969         rmstgloc)
3970           _rmstgloc;;
3971         rmstream)
3972           _rmstream;;
3973         rmtag)
3974           _rmtag;;
3975         rmtrigger)
3976           _rmtrigger;;
3977         rmtype)
3978           _rmtype;;
3979         rmver)
3980           COMPREPLY=($(compgen -W "$_rmver_opts" -- $cur));;
3981         rmview)
3982           _rmview;;
3983         rmvob)
3984           _rmvob;;
3985         schedule)
3986           COMPREPLY=($(compgen -W "$_schedule_opts" -- $cur));;
3987         setcache)
3988           COMPREPLY=($(compgen -W "$_setcache_opts" -- $cur));;
3989         setcs)
3990           _setcs;;
3991         setview)
3992           _setview;;
3993         setplevel)
3994           _setplevel;;
3995         setsite)
3996           COMPREPLY=($(compgen -W "$_setsite_opts" -- $cur));;
3997         space)
3998           _space;;
3999         startview)
4000           _startview;;
4001         umount)
4002           _umount;;
4003         uncheckout|unco)
4004           COMPREPLY=($(compgen -W "$_uncheckout_opts" -- $cur));;
4005         unlock)
4006           _unlock;;
4007         unregister)
4008           COMPREPLY=($(compgen -W "$_unregister_opts" -- $cur));;
4009         unreserve)
4010           COMPREPLY=($(compgen -W "$_unreserve_opts" -- $cur));;
4011         update)
4012           COMPREPLY=($(compgen -W "$_update_opts" -- $cur));;
4013         winkin)
4014           COMPREPLY=($(compgen -W "$_winkin_opts" -- $cur));;
4015       esac
4016         fi
4017   fi
4018 } # _scm
4019
4020 # TODO: These functions aren't working very well yet.
4021 function _type_selector () {
4022   local cur prev prev2
4023
4024   cur="${COMP_WORDS[COMP_CWORD]}"
4025
4026   if (($COMP_CWORD - 1 >= 0)); then
4027     prev="${COMP_WORDS[COMP_CWORD-1]}"
4028   fi
4029   
4030   if (($COMP_CWORD - 2 >= 0)); then
4031     prev2="${COMP_WORDS[COMP_CWORD-2]}"
4032   fi
4033
4034   if [[ $prev == : ]]; then
4035         COMPREPLY=($(compgen -W "$(ct lstype -kind $prev2 -short -invob $dvob | grep ^$cur)" -- $cur))  
4036   elif [[ $cur == : ]]; then
4037         COMPREPLY=($(compgen -W "$(ct lstype -kind $prev -short -invob $dvob)"))  
4038   elif [[ $cur == * ]]; then
4039         COMPREPLY=($(compgen -W "$_type_selectors" -- $cur))
4040   fi    
4041 } # _type_selector
4042
4043 function _object_selector () {
4044   local cur prev prev2
4045
4046   COMPREPLY=()
4047
4048   cur="${COMP_WORDS[COMP_CWORD]}"
4049   
4050   if (($COMP_CWORD - 1 >= 0)); then
4051     prev="${COMP_WORDS[COMP_CWORD-1]}"
4052   fi
4053   
4054   if (($COMP_CWORD - 2 >= 0)); then
4055     prev2="${COMP_WORDS[COMP_CWORD-2]}"
4056   fi
4057     
4058   if [[ $prev == activity || ($prev == : && $prev2 == activity) ]]; then
4059         if [[ $cur == : ]]; then
4060           COMPREPLY=($(compgen -W "$(_activities)" -- ""))
4061         else
4062           echo "cur = $cur"
4063           COMPREPLY=($(compgen -W "$(_activities $cur)"))
4064           echo "COMPREPLY = ${COMPREPLY[*]}"
4065         fi
4066   elif [[ $prev == lbtype || ($prev == : && $prev2 == lbtype) ]]; then
4067         if [[ $cur == : ]]; then
4068           COMPREPLY=($(compgen -W "$(_lbtypes)" -- ""))
4069           echo "COMPREPLY = ${COMPREPLY[*]}"
4070         else
4071           echo "cur = $cur"
4072           COMPREPLY=($(compgen -W "$(_lbtypes $cur)"))
4073           echo "COMPREPLY = ${COMPREPLY[*]}"
4074         fi      
4075   elif [[ $cur == * ]] ; then
4076     COMPREPLY=($(compgen -W "$_object_selectors" -- $cur))
4077   fi
4078 } # _object_selector
4079
4080 complete -o default -F _scm scm ct
4081
4082 complete -F _catcs       catcs
4083 complete -F _checkin     ci
4084 complete -F _deliver     deliver
4085 complete -F _endview     endview
4086 complete -F _lsactivity  lsact
4087 complete -F _lsbl        lsbl
4088 complete -F _lsproject   lsproj
4089 complete -F _lsfolder    lsfolder llfolder
4090 complete -F _lsstgloc    lsstgloc
4091 complete -F _lsstream    lsstream llstream
4092 complete -F _lsview      lsview llview
4093 complete -F _lsvob       lsvob llvob
4094 complete -F _merge       merge
4095 complete -F _mktag       mktag
4096 complete -F _mkview      mkview
4097 complete -F _rebase      rebase
4098 complete -F _rmtag       rmtag
4099 complete -F _rmview      rmview
4100 complete -F _setactivity setact
4101 complete -F _setcs       setcs
4102 complete -F _setview     setview
4103 complete -F _startview   startview
4104 complete -F _space       space
4105 complete -F _register    register
4106 complete -F _uncheckout  unco
4107 complete -F _unregister  unregister
4108
4109 complete -F _object_selector -o nospace lstype
4110 complete -F _object_selector -o nospace lltype
4111 complete -F _object_selector -o nospace lslock
4112 complete -F _object_selector -o nospace lllock