source: CMT/v1r18p20060505/source/cmt_commands.cxx

Last change on this file was 181, checked in by garonne, 18 years ago

add the cmt relocate command

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