source: CMT/HEAD/source/cmt_commands.cxx @ 659

Last change on this file since 659 was 659, checked in by rybkin, 10 years ago

See C.L. 518

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