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

Last change on this file since 656 was 656, checked in by rybkin, 11 years ago

See C.L. 515

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