source: CMT/v1r18p20050501/source/cmt_commands.cxx

Last change on this file was 42, checked in by arnault, 19 years ago

Preparing support for projects in CVS - See CL 270

  • Property svn:eol-style set to native
File size: 57.5 KB
Line 
1//-----------------------------------------------------------
2// Copyright Christian Arnault LAL-Orsay CNRS
3// arnault@lal.in2p3.fr
4// See the complete license in cmt_license.txt "http://www.cecill.info".
5//-----------------------------------------------------------
6
7#include "cmt_commands.h"
8#include "cmt_tag.h"
9#include "cmt_symbol.h"
10#include "cmt_project.h"
11
12ArgParser::ArgParser (CmtContext& context) : cmt(context), argc(0), argv(0), mode(Csh)
13{
14  arguments.clear ();
15
16  int i = 0;
17
18  parsers.add ("awk", i);
19  pv.push_back (&ArgParser::do_awk); i++;
20
21  parsers.add ("br", i);
22  parsers.add ("bro", i);
23  parsers.add ("broa", i);
24  parsers.add ("broad", i);
25  parsers.add ("broadc", i);
26  parsers.add ("broadca", i);
27  parsers.add ("broadcas", i);
28  parsers.add ("broadcast", i);
29  pv.push_back (&ArgParser::do_broadcast); i++;
30
31  parsers.add ("bu", i);
32  parsers.add ("bui", i);
33  parsers.add ("buil", i);
34  parsers.add ("build", i);
35  pv.push_back (&ArgParser::do_build); i++;
36
37  parsers.add ("check", i);
38  pv.push_back (&ArgParser::do_check); i++;
39
40  parsers.add ("check_f", i);
41  parsers.add ("check_fi", i);
42  parsers.add ("check_fil", i);
43  parsers.add ("check_file", i);
44  parsers.add ("check_files", i);
45  pv.push_back (&ArgParser::do_check_files); i++;
46
47  parsers.add ("co", i);
48  parsers.add ("checkout", i);
49  pv.push_back (&ArgParser::do_checkout); i++;
50
51  parsers.add ("cl", i);
52  parsers.add ("cle", i);
53  parsers.add ("clea", i);
54  parsers.add ("clean", i);
55  parsers.add ("cleanu", i);
56  parsers.add ("cleanup", i);
57  pv.push_back (&ArgParser::do_cleanup); i++;
58
59  parsers.add ("con", i);
60  parsers.add ("conf", i);
61  parsers.add ("confi", i);
62  parsers.add ("config", i);
63  pv.push_back (&ArgParser::do_config); i++;
64
65  parsers.add ("create", i);
66  pv.push_back (&ArgParser::do_create); i++;
67
68  parsers.add ("create_project", i);
69  pv.push_back (&ArgParser::do_create_project); i++;
70
71  parsers.add ("cvsb", i);
72  parsers.add ("cvsbr", i);
73  parsers.add ("cvsbra", i);
74  parsers.add ("cvsbran", i);
75  parsers.add ("cvsbranc", i);
76  parsers.add ("cvsbranch", i);
77  parsers.add ("cvsbranche", i);
78  parsers.add ("cvsbranches", i);
79  pv.push_back (&ArgParser::do_cvsbranches); i++;
80
81  parsers.add ("cvssubpa", i);
82  parsers.add ("cvssubpac", i);
83  parsers.add ("cvssubpack", i);
84  parsers.add ("cvssubpacka", i);
85  parsers.add ("cvssubpackag", i);
86  parsers.add ("cvssubpackage", i);
87  parsers.add ("cvssubpackages", i);
88  pv.push_back (&ArgParser::do_cvssubpackages); i++;
89
90  parsers.add ("cvssubpr", i);
91  parsers.add ("cvssubpro", i);
92  parsers.add ("cvssubproj", i);
93  parsers.add ("cvssubproje", i);
94  parsers.add ("cvssubprojec", i);
95  parsers.add ("cvssubproject", i);
96  parsers.add ("cvssubprojects", i);
97  pv.push_back (&ArgParser::do_cvssubprojects); i++;
98
99  parsers.add ("cvst", i);
100  parsers.add ("cvsta", i);
101  parsers.add ("cvstag", i);
102  parsers.add ("cvstags", i);
103  pv.push_back (&ArgParser::do_cvstags); i++;
104
105  parsers.add ("d", i);
106  parsers.add ("do", i);
107  pv.push_back (&ArgParser::do_do); i++;
108
109  parsers.add ("e", i);
110  parsers.add ("ex", i);
111  parsers.add ("exp", i);
112  parsers.add ("expa", i);
113  parsers.add ("expan", i);
114  parsers.add ("expand", i);
115  pv.push_back (&ArgParser::do_expand); i++;
116
117  parsers.add ("f", i);
118  parsers.add ("fi", i);
119  parsers.add ("fil", i);
120  parsers.add ("filt", i);
121  parsers.add ("filte", i);
122  parsers.add ("filter", i);
123  pv.push_back (&ArgParser::do_filter); i++;
124
125  parsers.add ("h", i);
126  parsers.add ("he", i);
127  parsers.add ("hel", i);
128  parsers.add ("help", i);
129  pv.push_back (&ArgParser::do_help); i++;
130
131  parsers.add ("l", i);
132  parsers.add ("lo", i);
133  parsers.add ("loc", i);
134  parsers.add ("lock", i);
135  pv.push_back (&ArgParser::do_lock); i++;
136
137  parsers.add ("re", i);
138  parsers.add ("rem", i);
139  parsers.add ("remo", i);
140  parsers.add ("remov", i);
141  parsers.add ("remove", i);
142  pv.push_back (&ArgParser::do_remove); i++;
143
144  parsers.add ("run", i);
145  pv.push_back (&ArgParser::do_run); i++;
146
147  parsers.add ("run_sequence", i);
148  pv.push_back (&ArgParser::do_run_sequence); i++;
149
150  parsers.add ("set", i);
151  pv.push_back (&ArgParser::do_set); i++;
152
153  parsers.add ("setup", i);
154  pv.push_back (&ArgParser::do_setup); i++;
155
156  parsers.add ("sh", i);
157  parsers.add ("sho", i);
158  parsers.add ("show", i);
159  pv.push_back (&ArgParser::do_show); i++;
160
161  parsers.add ("sy", i);
162  parsers.add ("sys", i);
163  parsers.add ("syst", i);
164  parsers.add ("syste", i);
165  parsers.add ("system", i);
166  pv.push_back (&ArgParser::do_system); i++;
167
168  parsers.add ("u", i);
169  parsers.add ("un", i);
170  parsers.add ("unl", i);
171  parsers.add ("unlo", i);
172  parsers.add ("unloc", i);
173  parsers.add ("unlock", i);
174  pv.push_back (&ArgParser::do_unlock); i++;
175
176  parsers.add ("v", i);
177  parsers.add ("ve", i);
178  parsers.add ("ver", i);
179  parsers.add ("vers", i);
180  parsers.add ("versi", i);
181  parsers.add ("versio", i);
182  parsers.add ("version", i);
183  parsers.add ("--version", i);
184  pv.push_back (&ArgParser::do_version); i++;
185
186  parsers.add ("-b", i);
187  parsers.add ("-ba", i);
188  parsers.add ("-bat", i);
189  pv.push_back (&ArgParser::option_bat); i++;
190
191  parsers.add ("-c", i);
192  parsers.add ("-cs", i);
193  parsers.add ("-csh", i);
194  pv.push_back (&ArgParser::option_csh); i++;
195
196  parsers.add ("-e", i);
197  pv.push_back (&ArgParser::option_e); i++;
198
199  parsers.add ("-f", i);
200  pv.push_back (&ArgParser::option_f); i++;
201
202  parsers.add ("-h", i);
203  parsers.add ("-he", i);
204  parsers.add ("-hel", i);
205  parsers.add ("-help", i);
206  parsers.add ("--h", i);
207  parsers.add ("--he", i);
208  parsers.add ("--hel", i);
209  parsers.add ("--help", i);
210  pv.push_back (&ArgParser::option_help); i++;
211
212  parsers.add ("-ho", i);
213  parsers.add ("-hom", i);
214  parsers.add ("-home", i);
215  pv.push_back (&ArgParser::option_home); i++;
216
217  parsers.add ("-n", i);
218  pv.push_back (&ArgParser::option_n); i++;
219
220  parsers.add ("-no_c", i);
221  parsers.add ("-no_cl", i);
222  parsers.add ("-no_cle", i);
223  parsers.add ("-no_clea", i);
224  parsers.add ("-no_clean", i);
225  parsers.add ("-no_cleanu", i);
226  parsers.add ("-no_cleanup", i);
227  pv.push_back (&ArgParser::option_no_cleanup); i++;
228
229  parsers.add ("-pac", i);
230  parsers.add ("-pack", i);
231  pv.push_back (&ArgParser::option_pack); i++;
232
233  parsers.add ("-pat", i);
234  parsers.add ("-path", i);
235  pv.push_back (&ArgParser::option_path); i++;
236
237  parsers.add ("-pr", i);
238  parsers.add ("-pri", i);
239  parsers.add ("-priv", i);
240  parsers.add ("-priva", i);
241  parsers.add ("-privat", i);
242  parsers.add ("-private", i);
243  pv.push_back (&ArgParser::option_private); i++;
244
245  parsers.add ("-pu", i);
246  parsers.add ("-pub", i);
247  parsers.add ("-publ", i);
248  parsers.add ("-publi", i);
249  parsers.add ("-public", i);
250  pv.push_back (&ArgParser::option_public); i++;
251
252  parsers.add ("-s", i);
253  parsers.add ("-sh", i);
254  pv.push_back (&ArgParser::option_sh); i++;
255
256  parsers.add ("-q", i);
257  parsers.add ("-qu", i);
258  parsers.add ("-qui", i);
259  parsers.add ("-quie", i);
260  parsers.add ("-quiet", i);
261  pv.push_back (&ArgParser::option_quiet); i++;
262
263  parsers.add ("-tag", i);
264  pv.push_back (&ArgParser::option_tag); i++;
265
266  parsers.add ("-tag_add", i);
267  pv.push_back (&ArgParser::option_tag_add); i++;
268
269  parsers.add ("-tag_remove", i);
270  pv.push_back (&ArgParser::option_tag_remove); i++;
271
272  parsers.add ("-u", i);
273  parsers.add ("-us", i);
274  parsers.add ("-use", i);
275  pv.push_back (&ArgParser::option_use); i++;
276
277  parsers.add ("-user", i);
278  parsers.add ("-user_", i);
279  parsers.add ("-user_c", i);
280  parsers.add ("-user_co", i);
281  parsers.add ("-user_con", i);
282  parsers.add ("-user_cont", i);
283  parsers.add ("-user_conte", i);
284  parsers.add ("-user_contex", i);
285  parsers.add ("-user_context", i);
286  pv.push_back (&ArgParser::option_user_context); i++;
287
288  parsers.add ("-v", i);
289  parsers.add ("-ve", i);
290  parsers.add ("-ver", i);
291  parsers.add ("-vers", i);
292  parsers.add ("-versi", i);
293  parsers.add ("-versio", i);
294  parsers.add ("-version", i);
295  pv.push_back (&ArgParser::option_version); i++;
296
297  parsers.add ("-with_v", i);
298  parsers.add ("-with_ve", i);
299  parsers.add ("-with_ver", i);
300  parsers.add ("-with_vers", i);
301  parsers.add ("-with_versi", i);
302  parsers.add ("-with_versio", i);
303  parsers.add ("-with_version", i);
304  parsers.add ("-with_version_", i);
305  parsers.add ("-with_version_d", i);
306  parsers.add ("-with_version_di", i);
307  parsers.add ("-with_version_dir", i);
308  parsers.add ("-with_version_dire", i);
309  parsers.add ("-with_version_direc", i);
310  parsers.add ("-with_version_direct", i);
311  parsers.add ("-with_version_directo", i);
312  parsers.add ("-with_version_director", i);
313  parsers.add ("-with_version_directory", i);
314  pv.push_back (&ArgParser::option_with_version_directory); i++;
315
316  parsers.add ("-without_v", i);
317  parsers.add ("-without_ve", i);
318  parsers.add ("-without_ver", i);
319  parsers.add ("-without_vers", i);
320  parsers.add ("-without_versi", i);
321  parsers.add ("-without_versio", i);
322  parsers.add ("-without_version", i);
323  parsers.add ("-without_version_", i);
324  parsers.add ("-without_version_d", i);
325  parsers.add ("-without_version_di", i);
326  parsers.add ("-without_version_dir", i);
327  parsers.add ("-without_version_dire", i);
328  parsers.add ("-without_version_direc", i);
329  parsers.add ("-without_version_direct", i);
330  parsers.add ("-without_version_directo", i);
331  parsers.add ("-without_version_director", i);
332  parsers.add ("-without_version_directory", i);
333  pv.push_back (&ArgParser::option_without_version_directory); i++;
334
335}
336
337void ArgParser::shift ()
338{
339  if (argc > 0)
340    {
341      argc--;
342      argv++;
343    }
344}
345
346void ArgParser::unshift ()
347{
348  argc++;
349  argv--;
350}
351
352void ArgParser::fill_arguments ()
353{
354  while (argc > 0)
355    {
356      cmt_string& s = arguments.add ();
357      s = argv[0];
358
359      //cerr << "Getting arg[" << s << "] " << endl;
360
361      shift ();
362    } 
363}
364
365cmt_string& ArgParser::fill_one_argument ()
366{
367  if (argc > 0)
368    {
369      cmt_string& s = arguments.add ();
370      s = argv[0];
371
372      //cerr << "Getting arg[" << s << "] " << endl;
373
374      shift ();
375
376      return (s);
377    }
378  else
379    {
380      static cmt_string empty = "";
381      return (empty);
382    }
383}
384
385cmt_string& ArgParser::fill_one_argument_filtered ()
386{
387  if (argc > 0)
388    {
389      cmt_string& s = arguments.add ();
390      s = argv[0];
391
392      if (s[0] == '-')
393        {
394          s = "";
395        }
396
397      //cerr << "Getting arg[" << s << "] " << endl;
398
399      shift ();
400
401      return (s);
402    }
403  else
404    {
405      static cmt_string empty = "";
406      return (empty);
407    }
408}
409
410void ArgParser::parse ()
411{
412  ArgParser& me = *this;
413
414  help_action = action_none;
415  arguments.clear ();
416  extra_line.erase (0);
417  extra_file.erase (0);
418  mode = Csh;
419
420  /// Skip first argument ("cmt")
421  shift ();
422
423  cmt.m_action = action_none;
424
425  while (argc > 0)
426    {
427      arg = argv[0];
428
429      shift ();
430
431      /// Suppress trailing carriage-return
432      int cr = arg.find ('\r');
433      if (cr != cmt_string::npos) arg.erase (cr);
434
435      /// Suppress enclosing quotes
436      if ((arg[0] == '\"') && (arg[arg.size () - 1] == '\"'))
437        {
438          arg.erase (0, 1);
439          arg.erase (arg.size () - 1, 1);
440        }
441
442      /// Detect and split arguments of the form a=b
443      /// left and right part of this argument
444      cmt_string reduced_arg = arg;
445      int pos = reduced_arg.find ('=');
446      if (pos != cmt_string::npos)
447        {
448          reduced_arg.erase (pos);
449          arg.erase (0, pos+1);
450        }
451      else
452        {
453          arg = "";
454        }
455
456      //cerr << "argc=" << argc << " reduced_arg=[" << reduced_arg << "] arg=[" << arg << "]" << endl;
457
458      if (parsers.has (reduced_arg))
459        {
460          // This argument corresponds to a known command
461
462          int i = (*parsers.find (reduced_arg));
463
464          parser p = pv[i];
465          (me.*p) ();
466        }
467      else if (cmt.m_action != action_none)
468        {
469          // We have unexpected arguments (not handled by the command handler). This may sign
470          // an unprotected handler implementation.
471          if (!cmt.m_quiet) cerr << "#CMT> warning : unexpected parameter " << reduced_arg << endl;
472        }
473      else
474        {
475          // This argument does not correspond to a known command. We expect then an action
476          // to be executed with that name
477
478          unshift ();
479          do_do ();
480
481          /*
482              if (!cmt.m_quiet) cerr << "#CMT> syntax error : bad command parameter " << arg << endl;
483              help_action = action_none;
484          */
485        }
486    }
487}
488
489void ArgParser::do_awk ()
490{
491  fill_arguments ();
492  cmt.m_action = action_awk;
493}
494
495void ArgParser::do_broadcast ()
496{
497  fill_arguments ();
498  cmt.m_action = action_broadcast;
499 
500  if (cmt.m_scope_filtering_mode == default_filtering_mode)
501    {
502      cmt.m_scope_filtering_mode = reach_private_uses;
503    }
504}
505
506void ArgParser::do_build ()
507{
508  if (argc > 0)
509    {
510      arg = argv[0];
511
512      if (arg == "-nmake")
513        {
514          cmt.m_build_nmake = true;
515          shift ();
516        }
517    }
518
519  if (argc > 0)
520    {
521      arg = argv[0];
522
523      shift ();
524
525      if (arg == "constituent_makefile")
526        {
527          if (argc > 0)
528            {
529              fill_one_argument ();
530              cmt.m_action = action_build_constituent_makefile;
531            }
532          else
533            {
534              if (!cmt.m_quiet) cerr << "#CMT> syntax error : constituent name missing" << endl;
535              cmt.m_action = action_build_constituent_makefile;
536              help_action = action_help;
537            }
538        }
539      else if (arg == "constituents_makefile")
540        {
541          fill_arguments ();
542          cmt.m_action = action_build_constituents_makefile;
543        }
544      else if (arg == "dependencies")
545        {
546          if (argc > 0)
547            {
548              fill_arguments ();
549              cmt.m_action = action_build_dependencies;
550            }
551          else
552            {
553              if (!cmt.m_quiet) cerr << "#CMT> syntax error : arguments missing " << endl;
554              help_action = action_help;
555              cmt.m_action = action_build_dependencies;
556            }
557        }
558      else if (arg == "library_links")
559        {
560          cmt.m_action = action_build_library_links;
561        }
562      else if (arg == "make_setup")
563        {
564          cmt.m_action = action_build_make_setup;
565        }
566      else if (arg == "msdev")
567        {
568          if (argc > 0)
569            {
570              fill_one_argument_filtered ();
571            }
572
573          cmt.m_action = action_build_msdev;
574        }
575      else if (arg == "CMT_pacman")
576        {
577          cmt.m_action = action_build_CMT_pacman;
578        }
579      else if (arg == "vsnet") 
580        {
581          if (argc > 0)
582            {
583              fill_one_argument_filtered ();
584            }
585                                                                   
586          cmt.m_action = action_build_vsnet;                 
587        }                                             
588      else if (arg == "os9_makefile")
589        {
590          if (argc > 0)
591            {
592              fill_one_argument ();
593              cmt.m_action = action_build_os9_makefile;
594            }
595          else
596            {
597              if (!cmt.m_quiet) cerr << "#CMT> syntax error : arguments missing " << endl;
598              help_action = action_help;
599              cmt.m_action = action_build_os9_makefile;
600            }
601        }
602      else if (arg == "prototype")
603        {
604          if (argc > 0)
605            {
606              fill_one_argument ();
607              cmt.m_action = action_build_prototype;
608            }
609          else
610            {
611              if (!cmt.m_quiet) cerr << "#CMT> syntax error : arguments missing" << endl;
612              help_action = action_help;
613              cmt.m_action = action_build_prototype;
614            }
615        }
616      else if (arg == "readme")
617        {
618          cmt.m_action = action_build_readme;
619
620          fill_arguments ();
621        }
622      else if (arg == "tag_makefile")
623        {
624          cmt.m_action = action_build_tag_makefile;
625        }
626      else if (arg == "temporary_name")
627        {
628          cmt.m_action = action_build_temporary_name;
629        }
630      else if (arg == "triggers")
631        {
632          if (argc > 0)
633            {
634              fill_one_argument ();
635              cmt.m_action = action_build_triggers;
636            }
637          else
638            {
639              if (!cmt.m_quiet) cerr << "#CMT> syntax error : arguments missing" << endl;
640              help_action = action_help;
641              cmt.m_action = action_build_triggers;
642            }
643        }
644      else if (arg == "windefs")
645        {
646          if (argc > 0)
647            {
648              fill_one_argument ();
649              cmt.m_action = action_build_windefs;
650            }
651          else
652            {
653              if (!cmt.m_quiet) cerr << "#CMT> syntax error : arguments missing" << endl;
654              help_action = action_help;
655              cmt.m_action = action_build_windefs;
656            }
657        }
658      else
659        {
660          if (!cmt.m_quiet) cerr << "#CMT> syntax error : wrong build argument" << endl;
661          help_action = action_help;
662          cmt.m_action = action_build;
663        }
664    }
665  else
666    {
667      if (!cmt.m_quiet) cerr << "#CMT> syntax error : don't know what to build" << endl;
668      help_action = action_help;
669      cmt.m_action = action_build;
670    }
671}
672
673void ArgParser::do_check ()
674{
675  if (argc > 0)
676    {
677      arg = argv[0];
678
679      shift ();
680
681      if (arg == "configuration")
682        {
683          cmt.m_action = action_check_configuration;
684        }
685      else if (arg == "files")
686        {
687          if (argc > 0)
688            {
689              fill_one_argument ();
690              if (argc > 0)
691                {
692                  fill_one_argument ();
693                  cmt.m_action = action_check_files;
694                }
695              else
696                {
697                  if (!cmt.m_quiet) cerr << "#CMT> syntax error : reference file name missing" 
698                                         << endl;
699                  help_action = action_help;
700                  cmt.m_action = action_check_files;
701                }
702            }
703          else
704            {
705              if (!cmt.m_quiet) cerr << "#CMT> syntax error : file name missing" << endl;
706              help_action = action_help;
707              cmt.m_action = action_check_files;
708            }
709        }
710      else if (arg == "version")
711        {
712          if (argc > 0)
713            {
714              fill_one_argument ();
715              cmt.m_action = action_check_version;
716            }
717          else
718            {
719              if (!cmt.m_quiet) cerr << "#CMT> syntax error : package name missing" << endl;
720              help_action = action_help;
721              cmt.m_action = action_check_version;
722            }
723        }
724      else
725        {
726          if (!cmt.m_quiet) cerr << "#CMT> syntax error : bad check option" << endl;
727          help_action = action_help;
728          cmt.m_action = action_check;
729        }
730    }
731  else
732    {
733      if (!cmt.m_quiet) cerr << "#CMT> syntax error : don't know what to check" << endl;
734      help_action = action_help;
735      cmt.m_action = action_check;
736    }
737}
738
739void ArgParser::do_check_files ()
740{
741  if (argc > 0)
742    {
743      fill_one_argument ();
744      if (argc > 0)
745        {
746          fill_one_argument ();
747          cmt.m_action = action_check_files;
748        }
749      else
750        {
751          if (!cmt.m_quiet) cerr << "#CMT> syntax error : reference file missing" << endl;
752          help_action = action_help;
753          cmt.m_action = action_check_files;
754        }
755    }
756  else
757    {
758      if (!cmt.m_quiet) cerr << "#CMT> syntax error : file name missing" << endl;
759      help_action = action_help;
760      cmt.m_action = action_check_files;
761    }
762}
763
764void ArgParser::do_checkout ()
765{
766  if (argc > 0)
767    {
768      fill_arguments ();
769      cmt.m_action = action_checkout;
770    }
771  else
772    {
773      if (!cmt.m_quiet) cerr << "#CMT> syntax error : checkout arguments missing" << endl;
774      help_action = action_help;
775      cmt.m_action = action_checkout;
776    }
777}
778
779void ArgParser::do_cleanup ()
780{
781  cmt.m_action = action_cleanup;
782}
783
784void ArgParser::do_config ()
785{
786  cmt.m_action = action_config;
787}
788
789void ArgParser::do_create ()
790{
791  if (argc > 0)
792    {
793      fill_arguments ();
794      cmt.m_action = action_create;
795    }
796  else
797    {
798      if (!cmt.m_quiet) cerr << "#CMT> syntax error : create arguments missing" << endl;
799      help_action = action_help;
800      cmt.m_action = action_create;
801    }
802}
803
804void ArgParser::do_create_project ()
805{
806  if (argc > 0)
807    {
808      fill_arguments ();
809      cmt.m_action = action_create_project;
810    }
811  else
812    {
813      if (!cmt.m_quiet) cerr << "#CMT> syntax error : create_project arguments missing" << endl;
814      help_action = action_help;
815      cmt.m_action = action_create_project;
816    }
817}
818
819void ArgParser::do_cvsbranches ()
820{
821  if (argc > 0)
822    {
823      fill_one_argument ();
824      cmt.m_action = action_cvsbranches;
825    }
826  else
827    {
828      if (!cmt.m_quiet) cerr << "#CMT> syntax error : cvsbranches arguments missing" << endl;
829      help_action = action_help;
830      cmt.m_action = action_cvsbranches;
831    }
832}
833
834void ArgParser::do_cvssubpackages ()
835{
836  if (argc > 0)
837    {
838      fill_one_argument ();
839    }
840
841  cmt.m_action = action_cvssubpackages;
842}
843
844void ArgParser::do_cvssubprojects ()
845{
846  if (argc > 0)
847    {
848      fill_one_argument ();
849    }
850
851  cmt.m_action = action_cvssubprojects;
852}
853
854void ArgParser::do_cvstags ()
855{
856  if (argc > 0)
857    {
858      fill_arguments ();
859      cmt.m_action = action_cvstags;
860    }
861  else
862    {
863      if (!cmt.m_quiet) cerr << "#CMT> syntax error : package name missing" << endl;
864      help_action = action_help;
865      cmt.m_action = action_cvstags;
866    }
867}
868
869void ArgParser::do_do ()
870{
871  if (argc > 0)
872    {
873      fill_arguments ();
874                 
875      {
876        cmt_string tag_name = "target_";
877        tag_name += arguments[0];
878
879        Tag* tag;
880        tag = Tag::add (tag_name, PriorityUserTag, "action", 0);                     
881        tag->mark ();
882      }
883
884      cmt.m_action = action_do;
885    }
886  else
887    {
888      if (!cmt.m_quiet) cerr << "#CMT> syntax error : action not specified" << endl;
889      help_action = action_help;
890      cmt.m_action = action_do;
891    }
892}
893
894void ArgParser::do_expand ()
895{
896  if (argc > 0)
897    {
898      arg = argv[0];
899
900      shift ();
901      if (arg == "model")
902        {
903          if (argc > 0)
904            {
905              fill_arguments ();
906              cmt.m_action = action_expand_model;
907            }
908          else
909            {
910              if (!cmt.m_quiet) cerr << "#CMT> syntax error : model not specified" << endl;
911              help_action = action_help;
912              cmt.m_action = action_expand_model;
913            }
914        }
915      else
916        {
917          if (!cmt.m_quiet) cerr << "#CMT> syntax error : bad expand option" << endl;
918          help_action = action_help;
919          cmt.m_action = action_expand_model;
920        }
921    }
922  else
923    {
924      if (!cmt.m_quiet) cerr << "#CMT> syntax error : don't know what to expand" << endl;
925      help_action = action_help;
926      cmt.m_action = action_expand_model;
927    }
928}
929
930void ArgParser::do_filter ()
931{
932  if (argc > 0)
933    {
934      fill_arguments ();
935      cmt.m_action = action_filter;
936    }
937  else
938    {
939      if (!cmt.m_quiet) cerr << "#CMT> syntax error : file to filter not specified" << endl;
940      help_action = action_help;
941      cmt.m_action = action_filter;
942    }
943}
944
945void ArgParser::do_help ()
946{
947  help_action = action_help;
948}
949
950void ArgParser::do_lock ()
951{
952  if (argc > 0)
953    {
954      cmt.m_current_package = fill_one_argument ();
955      cmt.m_current_version.erase (0);
956      cmt.m_current_path.erase (0);
957
958      if (argc > 0)
959        {
960          cmt.m_current_version = fill_one_argument ();
961          cmt.m_action = action_lock;
962
963          if (argc > 0)
964            {
965              cmt.m_current_path = fill_one_argument_filtered ();
966            }
967
968          cmt.m_current_access = UserMode;
969          (Use::current()).set (cmt.m_current_package, 
970                                cmt.m_current_version, 
971                                cmt.m_current_path);
972
973        }
974      else
975        {
976          if (!cmt.m_quiet) cerr << "#CMT> syntax error : version missing" << endl;
977          help_action = action_help;
978          cmt.m_action = action_lock;
979        }
980    }
981  else
982    {
983      cmt.m_action = action_lock;
984    }
985}
986
987void ArgParser::do_remove ()
988{
989  if (argc > 0)
990    {
991      arg = argv[0];
992
993      if (arg == "library_links")
994        {
995          shift ();
996          cmt.m_action = action_remove_library_links;
997        }
998      else
999        {
1000          cmt.m_current_package = fill_one_argument ();
1001          cmt.m_current_version.erase (0);
1002          cmt.m_current_path.erase (0);
1003                     
1004          if (argc > 0)
1005            {
1006              cmt.m_current_version = fill_one_argument ();
1007
1008              if (argc > 0)
1009                {
1010                  cmt.m_current_path = fill_one_argument_filtered ();
1011                }
1012                           
1013              cmt.m_action = action_remove;
1014            }
1015          else
1016            {
1017              if (!cmt.m_quiet) cerr << "#CMT> syntax error : version missing" << endl;
1018              help_action = action_help;
1019              cmt.m_action = action_remove;
1020            }
1021        }
1022    }
1023  else
1024    {
1025      if (!cmt.m_quiet) cerr << "#CMT> syntax error : don't know what to remove" << endl;
1026      help_action = action_help;
1027      cmt.m_action = action_remove;
1028    }
1029}
1030
1031void ArgParser::do_run ()
1032{
1033  if (argc > 0)
1034    {
1035      fill_arguments ();
1036      cmt.m_action = action_run;
1037    }
1038  else
1039    {
1040      if (!cmt.m_quiet) cerr << "#CMT> syntax error : run arguments missing" << endl;
1041      help_action = action_help;
1042      cmt.m_action = action_run;
1043    }
1044}
1045
1046void ArgParser::do_run_sequence ()
1047{
1048  if (argc > 0)
1049    {
1050      fill_one_argument ();
1051      cmt.m_action = action_run_sequence;
1052    }
1053  else
1054    {
1055      if (!cmt.m_quiet) cerr << "#CMT> syntax error : run_sequence arguments missing" << endl;
1056      help_action = action_help;
1057      cmt.m_action = action_run_sequence;
1058    }
1059}
1060
1061void ArgParser::do_set ()
1062{
1063  if (argc > 0)
1064    {
1065      arg = argv[0];
1066
1067      shift ();
1068
1069      if (arg == "version")
1070        {
1071          fill_arguments ();
1072          cmt.m_action = action_set_version;
1073        }
1074      else if (arg == "versions")
1075        {
1076          fill_arguments ();
1077
1078          cmt.m_action = action_set_versions;
1079
1080          if (cmt.m_scope_filtering_mode == default_filtering_mode)
1081            {
1082              cmt.m_scope_filtering_mode = reach_private_uses;
1083            }
1084        }
1085      else
1086        {
1087          if (!cmt.m_quiet) cerr << "#CMT> syntax error : bad set argument" << endl;
1088          help_action = action_help;
1089          //cmt.m_action = action_set;
1090        }
1091    }
1092  else
1093    {
1094      if (!cmt.m_quiet) cerr << "#CMT> syntax error : don't know what to set" << endl;
1095      help_action = action_help;
1096      //cmt.m_action = action_set;
1097    }
1098}
1099
1100void ArgParser::do_setup ()
1101{
1102  cmt.m_action = action_setup;
1103}
1104
1105void ArgParser::do_show ()
1106{
1107  if (argc > 0)
1108    {
1109      arg = argv[0];
1110
1111      //cerr << "Running show arg=" << arg << endl;
1112
1113      shift ();
1114
1115      if (arg == "action")
1116        {
1117          if (argc > 0)
1118            {
1119              cmt.m_current_target = fill_one_argument ();
1120              cmt.m_action = action_show_action;
1121            }
1122          else
1123            {
1124              if (!cmt.m_quiet) cerr << "#CMT> syntax error : action name missing" << endl;
1125              help_action = action_help;
1126              cmt.m_action = action_show_action;
1127            }
1128        }
1129      else if (arg == "action_names")
1130        {
1131          if (argc > 0)
1132            {
1133              fill_one_argument ();
1134            }
1135
1136          cmt.m_action = action_show_action_names;
1137        }
1138      else if (arg == "action_value")
1139        {
1140          cmt.m_quiet = true;
1141          if (argc > 0)
1142            {
1143              cmt.m_current_target = fill_one_argument ();
1144              cmt.m_action = action_show_action_value;
1145            }
1146          else
1147            {
1148              if (!cmt.m_quiet) cerr << "#CMT> syntax error : action name missing" << endl;
1149              help_action = action_help;
1150              cmt.m_action = action_show_action_value;
1151            }
1152        }
1153      else if (arg == "actions")
1154        {
1155          if (argc > 0)
1156            {
1157              fill_one_argument ();
1158            }
1159
1160          cmt.m_action = action_show_actions;
1161        }
1162      else if (arg == "all_tags")
1163        {
1164          cmt.m_action = action_show_all_tags;
1165        }
1166      else if (arg == "applied_patterns")
1167        {
1168          cmt.m_action = action_show_applied_patterns;
1169        }
1170      else if (arg == "author")
1171        {
1172          cmt.m_action = action_show_author;
1173        }
1174      else if (arg == "branches")
1175        {
1176          cmt.m_action = action_show_branches;
1177        }
1178      else if (arg == "clients")
1179        {
1180          if (argc > 0)
1181            {
1182              cmt.m_current_target = fill_one_argument ();
1183
1184              cmt.m_action = action_show_clients;
1185
1186              if (argc > 0)
1187                {
1188                  fill_one_argument ();
1189                  if (argc > 0)
1190                    {
1191                      fill_one_argument ();
1192                    }
1193                }
1194            }
1195          else
1196            {
1197              if (!cmt.m_quiet) cerr << "#CMT> syntax error : package name missing" << endl;
1198              help_action = action_help;
1199              cmt.m_action = action_show_clients;
1200            }
1201        }
1202      else if (arg == "cmtpath_patterns")
1203        {
1204          cmt.m_action = action_show_cmtpath_patterns;
1205        }
1206      else if (arg == "constituent")
1207        {
1208          if (argc > 0)
1209            {
1210              cmt.m_current_target = fill_one_argument ();
1211              cmt.m_action = action_show_constituent;
1212            }
1213          else
1214            {
1215              if (!cmt.m_quiet) cerr << "#CMT> syntax error : constituent name missing" << endl;
1216              help_action = action_help;
1217              cmt.m_action = action_show_constituent;
1218            }
1219        }
1220      else if (arg == "constituent_names")
1221        {
1222          cmt.m_action = action_show_constituent_names;
1223        }
1224      else if (arg == "constituents")
1225        {
1226          cmt.m_action = action_show_constituents;
1227        }
1228      else if (arg == "cycles")
1229        {
1230          cmt.m_action = action_show_cycles;
1231        }
1232      else if (arg == "fragment")
1233        {
1234          if (argc > 0)
1235            {
1236              cmt.m_current_target = fill_one_argument ();
1237              cmt.m_action = action_show_fragment;
1238            }
1239          else
1240            {
1241              if (!cmt.m_quiet) cerr << "#CMT> syntax error : fragment name missing" << endl;
1242              help_action = action_help;
1243              cmt.m_action = action_show_fragment;
1244            }
1245        }
1246      else if (arg == "fragments")
1247        {
1248          cmt.m_action = action_show_fragments;
1249        }
1250      else if (arg == "groups")
1251        {
1252          cmt.m_action = action_show_groups;
1253        }
1254      else if (arg == "include_dirs")
1255        {
1256          cmt.m_action = action_show_include_dirs;
1257        }
1258      else if (arg == "language")
1259        {
1260          if (argc > 0)
1261            {
1262              cmt.m_current_target = fill_one_argument ();
1263              cmt.m_action = action_show_language;
1264            }
1265          else
1266            {
1267              if (!cmt.m_quiet) cerr << "#CMT> syntax error : language name missing" << endl;
1268              help_action = action_help;
1269              cmt.m_action = action_show_language;
1270            }
1271        }
1272      else if (arg == "languages")
1273        {
1274          cmt.m_action = action_show_languages;
1275        }
1276      else if (arg == "macro")
1277        {
1278          if (argc > 0)
1279            {
1280              cmt.m_current_target = fill_one_argument ();
1281              cmt.m_action = action_show_macro;
1282            }
1283          else
1284            {
1285              if (!cmt.m_quiet) cerr << "#CMT> syntax error : macro name missing" << endl;
1286              help_action = action_help;
1287              cmt.m_action = action_show_macro;
1288            }
1289        }
1290      else if (arg == "macro_names")
1291        {
1292          if (argc > 0)
1293            {
1294              fill_one_argument ();
1295            }
1296
1297          cmt.m_action = action_show_macro_names;
1298        }
1299      else if (arg == "macro_value")
1300        {
1301          cmt.m_quiet = true;
1302          if (argc > 0)
1303            {
1304              cmt.m_current_target = fill_one_argument ();
1305              cmt.m_action = action_show_macro_value;
1306            }
1307          else
1308            {
1309              if (!cmt.m_quiet) cerr << "#CMT> syntax error : macro name missing" << endl;
1310              help_action = action_help;
1311              cmt.m_action = action_show_macro_value;
1312            }
1313        }
1314      else if (arg == "macros")
1315        {
1316          if (argc > 0)
1317            {
1318              fill_one_argument ();
1319            }
1320
1321          cmt.m_action = action_show_macros;
1322        }
1323      else if (arg == "manager")
1324        {
1325          cmt.m_action = action_show_manager;
1326        }
1327      else if (arg == "packages")
1328        {
1329          if (argc > 0)
1330            {
1331              cmt.m_current_target = fill_one_argument ();
1332            }
1333
1334          cmt.m_action = action_show_packages;
1335        }
1336      else if (arg == "path")
1337        {
1338          cmt.m_action = action_show_path;
1339        }
1340      else if (arg == "pattern")
1341        {
1342          if (argc > 0)
1343            {
1344              cmt.m_current_target = fill_one_argument ();
1345              cmt.m_action = action_show_pattern;
1346            }
1347          else
1348            {
1349              if (!cmt.m_quiet) cerr << "#CMT> syntax error : pattern name missing" << endl;
1350              help_action = action_help;
1351              cmt.m_action = action_show_pattern;
1352            }
1353        }
1354      else if (arg == "pattern_names")
1355        {
1356          cmt.m_action = action_show_pattern_names;
1357        }
1358      else if (arg == "patterns")
1359        {
1360          cmt.m_action = action_show_patterns;
1361        }
1362      else if (arg == "projects")
1363        {
1364          cmt.m_action = action_show_projects;
1365        }
1366      else if (arg == "pwd")
1367        {
1368          cmt.m_action = action_show_pwd;
1369        }
1370      else if (arg == "setup")
1371        {
1372          cmt.m_action = action_show_setup;
1373
1374          if (cmt.m_scope_filtering_mode == default_filtering_mode)
1375            {
1376              cmt.m_scope_filtering_mode = reach_private_uses;
1377            }
1378        }
1379      else if (arg == "set_names")
1380        {
1381          if (argc > 0)
1382            {
1383              fill_one_argument ();
1384            }
1385
1386          cmt.m_action = action_show_set_names;
1387        }
1388      else if (arg == "set_value")
1389        {
1390          cmt.m_quiet = true;
1391          if (argc > 0)
1392            {
1393              cmt.m_current_target = fill_one_argument ();
1394              cmt.m_action = action_show_set_value;
1395            }
1396          else
1397            {
1398              if (!cmt.m_quiet) cerr << "#CMT> syntax error : set name missing" << endl;
1399              help_action = action_help;
1400              cmt.m_action = action_show_set_value;
1401            }
1402        }
1403      else if (arg == "set")
1404        {
1405          if (argc > 0)
1406            {
1407              cmt.m_current_target = fill_one_argument ();
1408              cmt.m_action = action_show_set;
1409            }
1410          else
1411            {
1412              if (!cmt.m_quiet) cerr << "#CMT> syntax error : set name missing" << endl;
1413              help_action = action_help;
1414              cmt.m_action = action_show_set;
1415            }
1416        }
1417      else if (arg == "sets")
1418        {
1419          if (argc > 0)
1420            {
1421              fill_one_argument ();
1422            }
1423
1424          cmt.m_action = action_show_sets;
1425        }
1426      else if (arg == "strategies")
1427        {
1428          cmt.m_action = action_show_strategies;
1429        }
1430      else if (arg == "tags")
1431        {
1432          cmt.m_action = action_show_tags;
1433        }
1434      else if (arg == "use_paths")
1435        {
1436          if (argc > 0)
1437            {
1438              while (argc > 0)
1439                {
1440                  if (strcmp (argv[0], "-private") == 0)
1441                    {
1442                      cmt.m_scope_filtering_mode = reach_private_uses;
1443                    }
1444                  else if (strcmp (argv[0], "--private") == 0)
1445                    {
1446                      cmt.m_scope_filtering_mode = reach_private_uses;
1447                    }
1448                  else
1449                    {
1450                      cmt_string& s = arguments.add ();
1451                      s = argv[0];
1452                    }
1453
1454                  shift ();
1455                }
1456
1457              cmt.m_action = action_show_use_paths;
1458            }
1459          else
1460            {
1461              if (!cmt.m_quiet) cerr << "#CMT> syntax error : package name missing" << endl;
1462              help_action = action_help;
1463              cmt.m_action = action_show_use_paths;
1464            }
1465        }
1466      else if ((arg == "u") ||
1467               (arg == "us") ||
1468               (arg == "use") ||
1469               (arg == "uses"))
1470        {
1471          cmt.m_action = action_show_uses;
1472
1473          if (cmt.m_scope_filtering_mode == default_filtering_mode)
1474            {
1475              cmt.m_scope_filtering_mode = reach_private_uses;
1476            }
1477        }
1478      else if (arg == "version")
1479        {
1480          cmt.m_action = action_show_version;
1481        }
1482      else if (arg == "versions")
1483        {
1484          if (argc > 0)
1485            {
1486              cmt.m_current_target = fill_one_argument ();
1487              cmt.m_action = action_show_versions;
1488            }
1489          else
1490            {
1491              if (!cmt.m_quiet) cerr << "#CMT> syntax error : package name missing" << endl;
1492              help_action = action_help;
1493              cmt.m_action = action_show_versions;
1494            }
1495        }
1496      else
1497        {
1498          if (!cmt.m_quiet) cerr << "#CMT> syntax error : bad show argument" << endl;
1499          help_action = action_help;
1500          cmt.m_action = action_show;
1501        }
1502    }
1503  else
1504    {
1505      if (!cmt.m_quiet) cerr << "#CMT> syntax error : don't know what to show" << endl;
1506      help_action = action_help;
1507      cmt.m_action = action_show;
1508    }
1509}
1510
1511void ArgParser::do_system ()
1512{
1513  cmt.m_action = action_system;
1514}
1515
1516void ArgParser::do_unlock ()
1517{
1518  if (argc > 0)
1519    {
1520      cmt.m_current_package = fill_one_argument ();
1521      cmt.m_current_version.erase (0);
1522      cmt.m_current_path.erase (0);
1523                                       
1524      if (argc > 0)
1525        {
1526          cmt.m_current_version = fill_one_argument ();
1527          cmt.m_action = action_unlock;
1528
1529          if (argc > 0)
1530            {
1531              cmt.m_current_path = fill_one_argument_filtered ();
1532            }
1533                                               
1534          cmt.m_current_access = UserMode;
1535          (Use::current()).set (cmt.m_current_package, 
1536                                cmt.m_current_version, 
1537                                cmt.m_current_path);
1538
1539        }
1540      else
1541        {
1542          if (!cmt.m_quiet) cerr << "#CMT> syntax error : version missing" << endl;
1543          help_action = action_help;
1544          cmt.m_action = action_unlock;
1545        }
1546    }
1547  else
1548    {
1549      cmt.m_action = action_unlock;
1550    }
1551}
1552
1553void ArgParser::do_version ()
1554{
1555  cmt.m_action = action_version;
1556}
1557
1558void ArgParser::option_help ()
1559{
1560  help_action = action_help;
1561}
1562
1563void ArgParser::option_n ()
1564{
1565  cmt.m_simulation = true;
1566}
1567
1568void ArgParser::option_quiet ()
1569{
1570  cmt.m_quiet = true;
1571}
1572
1573void ArgParser::option_csh ()
1574{
1575  mode = Csh;
1576}
1577
1578void ArgParser::option_sh ()
1579{
1580  mode = Sh;
1581}
1582
1583void ArgParser::option_bat ()
1584{
1585  mode = Bat;
1586}
1587
1588void ArgParser::option_use ()
1589{
1590  if (cmt.m_action != action_create)
1591    {
1592      CmtSystem::cmt_string_vector words;
1593
1594      CmtSystem::split (arg, ":", words);
1595
1596      cmt.m_current_access = UserMode;
1597
1598      if (words.size () > 0) cmt.m_current_package = words[0];
1599      if (words.size () > 1) cmt.m_current_version = words[1];
1600      if (words.size () > 2) cmt.m_current_path    = words[2];
1601      (Use::current()).set (cmt.m_current_package, 
1602                            cmt.m_current_version, 
1603                            cmt.m_current_path);
1604    }
1605}
1606
1607void ArgParser::option_pack ()
1608{
1609  if ((cmt.m_action != action_create) && (cmt.m_current_package != arg))
1610    {
1611      //CmtSystem::cd (cmt.m_default_path);
1612
1613      cmt.m_current_access = UserMode;
1614
1615      cmt.m_current_package = arg;
1616      cmt.m_current_version = "";
1617
1618      /*
1619      cerr << "ArgParser::option_pack> "
1620           << " cp=" << cmt.m_current_package
1621           << " cv=" << cmt.m_current_version
1622           << " cp=" << cmt.m_current_path << endl;
1623      */
1624
1625      (Use::current()).set (cmt.m_current_package, 
1626                            cmt.m_current_version, 
1627                            cmt.m_current_path);
1628    }
1629}
1630
1631void ArgParser::option_version ()
1632{
1633  if ((cmt.m_action != action_create) && (cmt.m_current_version != arg))
1634    {
1635      cmt.m_current_access = UserMode;
1636      cmt.m_current_version = arg;
1637
1638      /*
1639      cerr << "ArgParser::option_version> "
1640           << " cp=" << cmt.m_current_package
1641           << " cv=" << cmt.m_current_version
1642           << " cp=" << cmt.m_current_path << endl;
1643      */
1644
1645      (Use::current()).set (cmt.m_current_package, 
1646                            cmt.m_current_version, 
1647                            cmt.m_current_path);
1648    }
1649}
1650
1651void ArgParser::option_path ()
1652{
1653  if ((cmt.m_action != action_create) && (cmt.m_current_path != arg))
1654    {
1655      cmt.m_current_access = UserMode;
1656      cmt.m_current_path = arg;
1657
1658      /*
1659      cerr << "ArgParser::option_path> "
1660           << " cp=" << cmt.m_current_package
1661           << " cv=" << cmt.m_current_version
1662           << " cp=" << cmt.m_current_path << endl;
1663      */
1664
1665      (Use::current()).set (cmt.m_current_package, 
1666                            cmt.m_current_version, 
1667                            cmt.m_current_path);
1668
1669      //IProjectFactory& factory = ProjectFactory::instance ();
1670      //CmtSystem::add_cmt_path (cmt.m_current_path, "argument", factory);
1671    }
1672}
1673
1674void ArgParser::option_f ()
1675{
1676  extra_file = arg;
1677}
1678
1679void ArgParser::option_e ()
1680{
1681  cerr << "#CMT> Warning: extra statement = " << arg << endl;
1682  extra_line = arg;
1683}
1684
1685void ArgParser::option_home ()
1686{
1687  if (CmtSystem::test_directory (arg))
1688    {
1689      cmt.m_cmt_home = arg;
1690    }
1691}
1692
1693void ArgParser::option_tag ()
1694{
1695  /*
1696    Here we are going to change the complete tag set
1697  */
1698             
1699  if (arg != "")
1700    {
1701      Tag* tag;
1702      CmtSystem::cmt_string_vector words;
1703
1704      // First reset selection of all existing tags
1705      //Tag::clear_all ();
1706      Tag::unmark_all ();
1707      cmt.m_extra_tags = ",";
1708                   
1709      // Then restore CMTSITE
1710      Cmt::configure_version_tag ();
1711      Cmt::configure_site_tag (0);
1712      Cmt::configure_uname_tag ();
1713      Cmt::configure_hosttype_tag ();
1714      Cmt::configure_config_tag ();
1715      Cmt::configure_home (0);
1716      Cmt::guess_current_project ();
1717
1718      CmtSystem::split (arg, " \t,", words);
1719                 
1720      for (int i = 0; i < words.size (); i++)
1721        {
1722          const cmt_string& a = words[i];
1723                     
1724          cmt_string s = ",";
1725          s += a;
1726          s += ",";
1727                     
1728          if (i == 0)
1729            {
1730              cmt.m_current_tag = a;
1731                         
1732              if (CmtSystem::testenv ("TAGDEBUG")) cerr
1733                << "parse_argument(tag_add)> current_tag=" << cmt.m_current_tag << endl;
1734            }
1735                     
1736          if (cmt.m_extra_tags.find (s) == cmt_string::npos)
1737            {
1738              //if (!cmt.m_quiet) cerr << "  a=[" << a << "]" << endl;
1739                         
1740              // Then restore uname if the specified tag is CMTCONFIG
1741              if (a == CmtSystem::get_cmt_config ())
1742                {
1743                  Cmt::configure_uname_tag ();
1744                }
1745                         
1746              tag = Tag::add (a, PriorityArgument, "arguments", 0);
1747                         
1748              tag->mark ();
1749                         
1750              cmt.m_extra_tags += a;
1751              cmt.m_extra_tags += ",";
1752            }
1753        }
1754    }
1755}
1756
1757void ArgParser::option_tag_add ()
1758{
1759  Tag* tag;
1760  CmtSystem::cmt_string_vector words;
1761             
1762  //if (!cmt.m_quiet) cerr << "-tag_add=" << arg << endl;
1763
1764  CmtSystem::split (arg, " \t,", words);
1765
1766  for (int i = 0; i < words.size (); i++)
1767    {
1768      const cmt_string& a = words[i];
1769
1770      cmt_string s = ",";
1771      s += a;
1772      s += ",";
1773
1774      if (cmt.m_extra_tags.find (s) == cmt_string::npos)
1775        {
1776          //if (!cmt.m_quiet) cerr << "  a=[" << a << "]" << endl;
1777
1778          /// Then restore uname if the specified tag is CMTCONFIG
1779          if (a == CmtSystem::get_cmt_config ())
1780            {
1781              Cmt::configure_uname_tag ();
1782            }
1783                     
1784          tag = Tag::add (a, PriorityUserTag, "arguments", 0);
1785                     
1786          tag->mark ();
1787
1788          cmt.m_extra_tags += a;
1789          cmt.m_extra_tags += ",";
1790        }
1791    }
1792}
1793
1794void ArgParser::option_tag_remove ()
1795{
1796  Tag::TagPtrVector tags = Tag::tags ();
1797  int i;
1798  Tag* tag;
1799
1800  /*
1801    for (i = 0; i < tags.size (); i++)
1802    {
1803    tag = tags[i];
1804    if ((tag != 0) &&
1805    (tag->selected))
1806    {
1807    if (!cmt.m_quiet) cerr << "  original tag_list=" << tag->name << tag->priority << endl;
1808    }
1809    }
1810  */
1811
1812  CmtSystem::cmt_string_vector words;
1813
1814  //if (!cmt.m_quiet) cerr << "-arg_remove=" << arg << endl;
1815
1816  CmtSystem::split (arg, " \t,", words);
1817
1818  //
1819  // Now erase all entries in the old list that match
1820  // the specified tags
1821  //
1822
1823  for (i = 0; i < words.size (); i++)
1824    {
1825      const cmt_string& a = words[i];
1826
1827      cmt_string s = ",";
1828      s += a;
1829      s += ",";
1830
1831      int pos;
1832
1833      pos = cmt.m_extra_tags.find (s);
1834
1835      if (pos != cmt_string::npos)
1836        {
1837          cmt.m_extra_tags.erase (pos, s.size () - 1);
1838        }
1839
1840      //if (!cmt.m_quiet) cerr << "  tag_list=[" << tag_list << "]" << endl;
1841    }
1842
1843  //
1844  // Now reinject the purged list of tags into the database
1845  // exactly as when using -tag=<tag-list>
1846  //
1847
1848  /// First forget about all existing tags
1849      Tag::unmark_all ();
1850
1851      /// Then restore CMTSITE
1852        Cmt::configure_version_tag ();
1853        Cmt::configure_site_tag (0);
1854        Cmt::configure_uname_tag ();
1855        Cmt::configure_hosttype_tag ();
1856             
1857        CmtSystem::split (cmt.m_extra_tags, " \t,", words);
1858
1859        for (i = 0; i < words.size (); i++)
1860          {
1861            const cmt_string& a = words[i];
1862
1863            //fprintf (stderr, "  a=[%s]\n", a.c_str ());
1864
1865            /// Then restore uname if the specified tag is CMTCONFIG
1866              if (a == CmtSystem::get_cmt_config ())
1867                {
1868                  Cmt::configure_uname_tag ();
1869                }
1870
1871              if (i == 0)
1872                {
1873                  cmt.m_current_tag = a;
1874
1875                  //if (!cmt.m_quiet) cerr << "parse_argument(tag_remove)> current_tag="
1876                  //<< cmt.m_current_tag << endl;
1877
1878                  tag = Tag::add (a, PriorityTag, "restore configuration", 0);
1879                }
1880              else
1881                {
1882                  tag = Tag::add (a, PriorityUserTag, "restore configuration", 0);
1883                }
1884
1885              tag->mark ();
1886          }
1887}
1888
1889void ArgParser::option_user_context ()
1890{
1891  if (CmtSystem::test_directory (arg))
1892    {
1893      cmt.m_cmt_user_context = arg;
1894    }
1895}
1896
1897void ArgParser::option_with_version_directory ()
1898{
1899  cmt.m_current_structuring_style = with_version_directory;
1900}
1901
1902void ArgParser::option_without_version_directory ()
1903{
1904  cmt.m_current_structuring_style = without_version_directory;
1905}
1906
1907void ArgParser::option_no_cleanup ()
1908{
1909  //cmt.m_current_setup_strategy |= SetupNoCleanup;
1910}
1911
1912void ArgParser::option_private ()
1913{
1914  cmt.m_scope_filtering_mode = reach_private_uses;
1915}
1916
1917void ArgParser::option_public ()
1918{
1919  cmt.m_scope_filtering_mode = block_private_uses;
1920}
1921
1922
1923
1924
1925
1926
1927CommandHelp::HelpMap& CommandHelp::get_help ()
1928{
1929  static CommandHelp& me = instance ();
1930
1931  return (me.m_help);
1932}
1933
1934CommandHelp::HelpTexts& CommandHelp::get_help_texts ()
1935{
1936  static CommandHelp& me = instance ();
1937
1938  return (me.m_help_texts);
1939}
1940
1941const cmt_string& CommandHelp::get_help_text (ActionType key)
1942{
1943  static const HelpTexts& help = get_help_texts ();
1944
1945  const cmt_string& h = help[key];
1946  return (h);
1947}
1948
1949void CommandHelp::show_all ()
1950{
1951  static HelpTexts& help_texts = get_help_texts ();
1952
1953  cerr << "#> cmt command [option...]" << endl;
1954  cerr << "# command :" << endl;
1955
1956  int i;
1957
1958  for (i = 0; ; i++)
1959    {
1960      const cmt_string& s = help_texts[i];
1961      if (s == "") break;
1962      cerr << "#   " << s << endl;
1963    }
1964
1965  cerr << "# global options :" << endl;
1966
1967  cerr << "#   -quiet                  : don't print errors" << endl;
1968  cerr << "#   -use=<p>:<v>:<path>     : set package version path" << endl;
1969  cerr << "#   -pack=<package>         : set package" << endl;
1970  cerr << "#   -version=<version>      : set version" << endl;
1971  cerr << "#   -path=<path>            : set root path" << endl;
1972  cerr << "#   -f=<requirement-file>   : set input file" << endl;
1973  cerr << "#   -e=<statement>          : add a one line statement" << endl;
1974  cerr << "#   -tag=<tag-list>         : select a new tag-set" << endl;
1975  cerr << "#   -tag_add=<tag-list>     : add specific comma-separated tag(s)" << endl;
1976  cerr << "#   -tag_remove=<tag-list>  : remove specific comma-separated tag(s)" << endl;
1977  cerr << "#   -with_version_directory : reset to default structuring style" << endl;
1978  cerr << "#   -without_version_directory : switch structuring style" << endl;
1979  cerr << "#   -cleanup                : activate install area cleanup" << endl;
1980  cerr << "#   -no_cleanup             : inhibit install area cleanup" << endl;
1981}
1982
1983void CommandHelp::show (ActionType action)
1984{
1985  //cerr << "CommandHelp::show> action = " << action << endl;
1986
1987  static HelpTexts& help_texts = get_help_texts ();
1988
1989  if (action == action_build)
1990    {
1991      int i;
1992
1993      for (i = action_build_constituent_makefile; i <= action_build_windefs; i++)
1994        {
1995          const cmt_string& s = help_texts[i];
1996          cerr << "#   " << s << endl;
1997        }
1998    }
1999  if (action == action_check)
2000    {
2001      int i;
2002
2003      for (i = action_check_configuration; i <= action_check_version; i++)
2004        {
2005          const cmt_string& s = help_texts[i];
2006          cerr << "#   " << s << endl;
2007        }
2008    }
2009  else if (action == action_show)
2010    {
2011      int i;
2012
2013      for (i = (action_show + 1); i <= action_show_versions; i++)
2014        {
2015          const cmt_string& s = help_texts[i];
2016          cerr << "#   " << s << endl;
2017        }
2018    }
2019  else
2020    {
2021      const cmt_string& s = get_help_text (action);
2022      cerr << "#" << s << endl;
2023    }
2024}
2025
2026CommandHelp& CommandHelp::instance ()
2027{
2028  static CommandHelp me;
2029  return (me);
2030}
2031
2032CommandHelp::CommandHelp ()
2033{
2034  static HelpMap& help = m_help;
2035
2036  static HelpTexts& help_texts = m_help_texts;
2037
2038  help_texts.clear ();
2039
2040  help_texts.add () =  "none";
2041  help_texts.add () =  "awk";
2042  help_texts.add () =  "broadcast [-select=list] [-exclude=list] [-local] [-global] [-begin=pattern] [-depth=n] <command> : apply a command to [some of] the used packages";
2043  help_texts.add () =  "build <option>          : build actions. (Try cmt help build)";
2044  help_texts.add () =  "build constituent_makefile <constituent>  : generate constituent Makefile fragment";
2045  help_texts.add () =  "build constituents_makefile : generate constituents.make";
2046  help_texts.add () =  "build dependencies      : generate dependencies";
2047  help_texts.add () =  "build library_links     : build symbolic links towards all imported libraries";
2048  help_texts.add () =  "build make_setup        : build a compiled version of setup scripts";
2049  help_texts.add () =  "build msdev             : generate MSDEV files";
2050  help_texts.add () =  "build CMT_pacman        : generate PACMAN manifest file for CMT";
2051  help_texts.add () =  "build vsnet             : generate VS.NET files";
2052  help_texts.add () =  "build os9_makefile      : generate Makefile for OS9";
2053  help_texts.add () =  "build prototype         : generate prototype file";
2054  help_texts.add () =  "build readme            : generate README.html";
2055  help_texts.add () =  "build tag_makefile      : generate tag specific Makefile";
2056  help_texts.add () =  "build temporary_name    : generate a name for a temprary file";
2057  help_texts.add () =  "build triggers <constituent> : generate library trigger file";
2058  help_texts.add () =  "build windefs <library_name> : generate def file for Windows shared libraries";
2059  help_texts.add () =  "check <option>          : check actions. (Try cmt help check)";
2060  help_texts.add () =  "check configuration     : check configuration";
2061  help_texts.add () =  "check files <old> <new> : compare two files and overrides <old> by <new> if different";
2062  help_texts.add () =  "check version <name>    : check if a name follows a version tag syntax ";
2063  help_texts.add () =  "co | checkout           : perform a cvs checkout over a CMT package";
2064  help_texts.add () =  "cleanup [-csh|-sh|-bat] : generate a cleanup script";
2065  help_texts.add () =  "config                  : generate setup and cleanup scripts";
2066  help_texts.add () =  "create <package> <version> [<path>] : create and configure a new package";
2067  help_texts.add () =  "create_project <project> <name> [<path>] : create and configure a new project";
2068  help_texts.add () =  "cvsbranches <module>      : display the subdirectories for a module";
2069  help_texts.add () =  "cvssubpackages <module>   : display the subpackages for a module";
2070  help_texts.add () =  "cvssubprojects <module>   : display the subprojects for a module";
2071  help_texts.add () =  "cvstags <module>          : display the CVS tags for a module";
2072  help_texts.add () =  "do <action> [<param>=<value>] ... : Execute an action";
2073  help_texts.add () =  "expand model <model>    : ";
2074  help_texts.add () =  "filter <in> <out>       : filter a file against CMT macros and env. variables";
2075  help_texts.add () =  "help | -help | --help   : display this help";
2076  help_texts.add () =  "load";
2077  help_texts.add () =  "lock [<p> <v> [<path>]] : lock a package";
2078  help_texts.add () =  "remove <package> <version> [<path>] : remove a package version";
2079  help_texts.add () =  "remove library_links    : remove symbolic links towards all imported libraries";
2080  help_texts.add () =  "run '<command>'         : apply a command";
2081  help_texts.add () =  "run_sequence <sequence file> : execute a cmt equence file";
2082  help_texts.add () =  "set version <version>   : generate a version file in the current package";
2083  help_texts.add () =  "set versions            : generate version files into packages";
2084  help_texts.add () =  "setup [-csh|-sh|-bat]   : generate a setup script";
2085  help_texts.add () =  "show <option>           : query actions. (Try cmt help show)";
2086  help_texts.add () =  "show  action <name>     :  a formatted action definition";
2087  help_texts.add () =  "show  action_value <name> :  a raw action definition";
2088  help_texts.add () =  "show  action_names      :  all action names";
2089  help_texts.add () =  "show  actions           :  all action definitions";
2090  help_texts.add () =  "show  all_tags          :  all defined tags";
2091  help_texts.add () =  "show  applied_patterns  :  all patterns actually applied";
2092  help_texts.add () =  "show  author            :  package author";
2093  help_texts.add () =  "show  branches          :  added branches";
2094  help_texts.add () =  "show  clients           :  package clients";
2095  help_texts.add () =  "show  cmtpath_patterns  :  cmtpath_patterns";
2096  help_texts.add () =  "show  constituent <name>:  constituent definition";
2097  help_texts.add () =  "show  constituent_names :  constituent names";
2098  help_texts.add () =  "show  constituents      :  constituent definitions";
2099  help_texts.add () =  "show  cycles            :  cycles in the use graph";
2100  help_texts.add () =  "show  fragment <name>   :  one fragment definition";
2101  help_texts.add () =  "show  fragments         :  fragment definitions";
2102  help_texts.add () =  "show  groups            :  group definitions";
2103  help_texts.add () =  "show  include_dirs      :  ";
2104  help_texts.add () =  "show  language <name>   :  language definition";
2105  help_texts.add () =  "show  languages         :  language definitions";
2106  help_texts.add () =  "show  macro <name>      :  a formatted macro definition";
2107  help_texts.add () =  "show  macro_value <name>  :  a raw macro definition";
2108  help_texts.add () =  "show  macro_names       :  all macro names";
2109  help_texts.add () =  "show  macros            :  all macro definitions";
2110  help_texts.add () =  "show  manager           :  package manager";
2111  help_texts.add () =  "show  packages          :  packages reachable from the current context";
2112  help_texts.add () =  "show  path              :  the package search list";
2113  help_texts.add () =  "show  pattern <name>    :  the pattern definition and usages";
2114  help_texts.add () =  "show  pattern_names     :  pattern names";
2115  help_texts.add () =  "show  patterns          :  the pattern definitions";
2116  help_texts.add () =  "show  projects          :  project definitions";
2117  help_texts.add () =  "show  setup             :  setup definitions";
2118  help_texts.add () =  "show  pwd               :  filtered current directory";
2119  help_texts.add () =  "show  set <name>        :  a formatted set definition";
2120  help_texts.add () =  "show  set_names         :  set names";
2121  help_texts.add () =  "show  set_value <name>  :  a raw set definition";
2122  help_texts.add () =  "show  sets              :  set definitions";
2123  help_texts.add () =  "show  strategies        :  all strategies (build & version)";
2124  help_texts.add () =  "show  tags              :  all currently active tags";
2125  help_texts.add () =  "show  use_paths <pack>  :  all paths to the used package";
2126  help_texts.add () =  "show  uses              :  used packages";
2127  help_texts.add () =  "show  version           :  version of the current package";
2128  help_texts.add () =  "show  versions <name>   :  visible versions of the selected package";
2129  help_texts.add () =  "system                  : display the system tag";
2130  help_texts.add () =  "unlock [<p> <v> [<path>]] : unlock a package";
2131  help_texts.add () =  "version                 : version of CMT";
2132  help_texts.add () =  "";
2133
2134  //"build <key>             : build various components :"
2135  //"show <key>              : display various infos on :"
2136
2137  help.add (action_none, help_texts[action_none]);
2138  help.add (action_awk, help_texts[action_awk]);
2139  help.add (action_broadcast, help_texts[action_broadcast]);
2140  help.add (action_build, help_texts[action_build]);
2141  help.add (action_build_constituent_makefile, help_texts[action_build_constituent_makefile]);
2142  help.add (action_build_constituents_makefile, help_texts[action_build_constituents_makefile]);
2143  help.add (action_build_dependencies, help_texts[action_build_dependencies]);
2144  help.add (action_build_library_links, help_texts[action_build_library_links]);
2145  help.add (action_build_make_setup, help_texts[action_build_make_setup]);
2146  help.add (action_build_msdev, help_texts[action_build_msdev]);
2147  help.add (action_build_CMT_pacman, help_texts[action_build_CMT_pacman]);
2148  help.add (action_build_vsnet, help_texts[action_build_vsnet]);
2149  help.add (action_build_os9_makefile, help_texts[action_build_os9_makefile]);
2150  help.add (action_build_prototype, help_texts[action_build_prototype]);
2151  help.add (action_build_readme, help_texts[action_build_readme]);
2152  help.add (action_build_tag_makefile, help_texts[action_build_tag_makefile]);
2153  help.add (action_build_temporary_name, help_texts[action_build_temporary_name]);
2154  help.add (action_build_triggers, help_texts[action_build_triggers]);
2155  help.add (action_build_windefs, help_texts[action_build_windefs]);
2156  help.add (action_check_configuration, help_texts[action_check_configuration]);
2157  help.add (action_check_files, help_texts[action_check_files]);
2158  help.add (action_check_version, help_texts[action_check_version]);
2159  help.add (action_checkout, help_texts[action_checkout]);
2160  help.add (action_cleanup, help_texts[action_cleanup]);
2161  help.add (action_config, help_texts[action_config]);
2162  help.add (action_create, help_texts[action_create]);
2163  help.add (action_create_project, help_texts[action_create_project]);
2164  help.add (action_cvsbranches, help_texts[action_cvsbranches]);
2165  help.add (action_cvssubpackages, help_texts[action_cvssubpackages]);
2166  help.add (action_cvssubprojects, help_texts[action_cvssubprojects]);
2167  help.add (action_cvstags, help_texts[action_cvstags]);
2168  help.add (action_do, help_texts[action_do]);
2169  help.add (action_expand_model, help_texts[action_expand_model]);
2170  help.add (action_filter, help_texts[action_filter]);
2171  help.add (action_help, help_texts[action_help]);
2172  help.add (action_load, help_texts[action_load]);
2173  help.add (action_lock, help_texts[action_lock]);
2174  help.add (action_remove, help_texts[action_remove]);
2175  help.add (action_remove_library_links, help_texts[action_remove_library_links]);
2176  help.add (action_run, help_texts[action_run]);
2177  help.add (action_run_sequence, help_texts[action_run_sequence]);
2178  help.add (action_set_version, help_texts[action_set_version]);
2179  help.add (action_set_versions, help_texts[action_set_versions]);
2180  help.add (action_setup, help_texts[action_setup]);
2181  help.add (action_show, help_texts[action_show]);
2182  help.add (action_show_action, help_texts[action_show_action]);
2183  help.add (action_show_action_value, help_texts[action_show_action_value]);
2184  help.add (action_show_action_names, help_texts[action_show_action_names]);
2185  help.add (action_show_actions, help_texts[action_show_actions]);
2186  help.add (action_show_all_tags, help_texts[action_show_all_tags]);
2187  help.add (action_show_applied_patterns, help_texts[action_show_applied_patterns]);
2188  help.add (action_show_author, help_texts[action_show_author]);
2189  help.add (action_show_branches, help_texts[action_show_branches]);
2190  help.add (action_show_clients, help_texts[action_show_clients]);
2191  help.add (action_show_cmtpath_patterns, help_texts[action_show_cmtpath_patterns]);
2192  help.add (action_show_constituent, help_texts[action_show_constituent]);
2193  help.add (action_show_constituent_names, help_texts[action_show_constituent_names]);
2194  help.add (action_show_constituents, help_texts[action_show_constituents]);
2195  help.add (action_show_cycles, help_texts[action_show_cycles]);
2196  help.add (action_show_fragment, help_texts[action_show_fragment]);
2197  help.add (action_show_fragments, help_texts[action_show_fragments]);
2198  help.add (action_show_groups, help_texts[action_show_groups]);
2199  help.add (action_show_include_dirs, help_texts[action_show_include_dirs]);
2200  help.add (action_show_language, help_texts[action_show_language]);
2201  help.add (action_show_languages, help_texts[action_show_languages]);
2202  help.add (action_show_macro, help_texts[action_show_macro]);
2203  help.add (action_show_macro_value, help_texts[action_show_macro_value]);
2204  help.add (action_show_macro_names, help_texts[action_show_macro_names]);
2205  help.add (action_show_macros, help_texts[action_show_macros]);
2206  help.add (action_show_manager, help_texts[action_show_manager]);
2207  help.add (action_show_packages, help_texts[action_show_packages]);
2208  help.add (action_show_path, help_texts[action_show_path]);
2209  help.add (action_show_pattern, help_texts[action_show_pattern]);
2210  help.add (action_show_pattern_names, help_texts[action_show_pattern_names]);
2211  help.add (action_show_patterns, help_texts[action_show_patterns]);
2212  help.add (action_show_projects, help_texts[action_show_projects]);
2213  help.add (action_show_setup, help_texts[action_show_setup]);
2214  help.add (action_show_pwd, help_texts[action_show_pwd]);
2215  help.add (action_show_set, help_texts[action_show_set]);
2216  help.add (action_show_set_names, help_texts[action_show_set_names]);
2217  help.add (action_show_set_value, help_texts[action_show_set_value]);
2218  help.add (action_show_sets, help_texts[action_show_sets]);
2219  help.add (action_show_strategies, help_texts[action_show_strategies]);
2220  help.add (action_show_tags, help_texts[action_show_tags]);
2221  help.add (action_show_use_paths, help_texts[action_show_use_paths]);
2222  help.add (action_show_uses, help_texts[action_show_uses]);
2223  help.add (action_show_version, help_texts[action_show_version]);
2224  help.add (action_show_versions, help_texts[action_show_versions]);
2225  help.add (action_system, help_texts[action_system]);
2226  help.add (action_unlock, help_texts[action_unlock]);
2227  help.add (action_version, help_texts[action_version]);
2228}
2229
Note: See TracBrowser for help on using the repository browser.