00001
00002
00003
00004
00005
00006
00007 #include "cmt_commands.h"
00008 #include "cmt_tag.h"
00009 #include "cmt_symbol.h"
00010 #include "cmt_project.h"
00011
00012 ArgParser::ArgParser (CmtContext& context) : cmt(context), argc(0), argv(0), mode(Csh)
00013 {
00014 arguments.clear ();
00015
00016 int i = 0;
00017
00018 parsers.add ("awk", i);
00019 pv.push_back (&ArgParser::do_awk); i++;
00020
00021 parsers.add ("br", i);
00022 parsers.add ("bro", i);
00023 parsers.add ("broa", i);
00024 parsers.add ("broad", i);
00025 parsers.add ("broadc", i);
00026 parsers.add ("broadca", i);
00027 parsers.add ("broadcas", i);
00028 parsers.add ("broadcast", i);
00029 pv.push_back (&ArgParser::do_broadcast); i++;
00030
00031 parsers.add ("bu", i);
00032 parsers.add ("bui", i);
00033 parsers.add ("buil", i);
00034 parsers.add ("build", i);
00035 pv.push_back (&ArgParser::do_build); i++;
00036
00037 parsers.add ("check", i);
00038 pv.push_back (&ArgParser::do_check); i++;
00039
00040 parsers.add ("check_f", i);
00041 parsers.add ("check_fi", i);
00042 parsers.add ("check_fil", i);
00043 parsers.add ("check_file", i);
00044 parsers.add ("check_files", i);
00045 pv.push_back (&ArgParser::do_check_files); i++;
00046
00047 parsers.add ("co", i);
00048 parsers.add ("checkout", i);
00049 pv.push_back (&ArgParser::do_checkout); i++;
00050
00051 parsers.add ("cl", i);
00052 parsers.add ("cle", i);
00053 parsers.add ("clea", i);
00054 parsers.add ("clean", i);
00055 parsers.add ("cleanu", i);
00056 parsers.add ("cleanup", i);
00057 pv.push_back (&ArgParser::do_cleanup); i++;
00058
00059 parsers.add ("con", i);
00060 parsers.add ("conf", i);
00061 parsers.add ("confi", i);
00062 parsers.add ("config", i);
00063 pv.push_back (&ArgParser::do_config); i++;
00064
00065 parsers.add ("create", i);
00066 pv.push_back (&ArgParser::do_create); i++;
00067
00068 parsers.add ("create_project", i);
00069 pv.push_back (&ArgParser::do_create_project); i++;
00070
00071 parsers.add ("cvsb", i);
00072 parsers.add ("cvsbr", i);
00073 parsers.add ("cvsbra", i);
00074 parsers.add ("cvsbran", i);
00075 parsers.add ("cvsbranc", i);
00076 parsers.add ("cvsbranch", i);
00077 parsers.add ("cvsbranche", i);
00078 parsers.add ("cvsbranches", i);
00079 pv.push_back (&ArgParser::do_cvsbranches); i++;
00080
00081 parsers.add ("cvssubpa", i);
00082 parsers.add ("cvssubpac", i);
00083 parsers.add ("cvssubpack", i);
00084 parsers.add ("cvssubpacka", i);
00085 parsers.add ("cvssubpackag", i);
00086 parsers.add ("cvssubpackage", i);
00087 parsers.add ("cvssubpackages", i);
00088 pv.push_back (&ArgParser::do_cvssubpackages); i++;
00089
00090 parsers.add ("cvssubpr", i);
00091 parsers.add ("cvssubpro", i);
00092 parsers.add ("cvssubproj", i);
00093 parsers.add ("cvssubproje", i);
00094 parsers.add ("cvssubprojec", i);
00095 parsers.add ("cvssubproject", i);
00096 parsers.add ("cvssubprojects", i);
00097 pv.push_back (&ArgParser::do_cvssubprojects); i++;
00098
00099 parsers.add ("cvst", i);
00100 parsers.add ("cvsta", i);
00101 parsers.add ("cvstag", i);
00102 parsers.add ("cvstags", i);
00103 pv.push_back (&ArgParser::do_cvstags); i++;
00104
00105 parsers.add ("d", i);
00106 parsers.add ("do", i);
00107 pv.push_back (&ArgParser::do_do); i++;
00108
00109 parsers.add ("e", i);
00110 parsers.add ("ex", i);
00111 parsers.add ("exp", i);
00112 parsers.add ("expa", i);
00113 parsers.add ("expan", i);
00114 parsers.add ("expand", i);
00115 pv.push_back (&ArgParser::do_expand); i++;
00116
00117 parsers.add ("f", i);
00118 parsers.add ("fi", i);
00119 parsers.add ("fil", i);
00120 parsers.add ("filt", i);
00121 parsers.add ("filte", i);
00122 parsers.add ("filter", i);
00123 pv.push_back (&ArgParser::do_filter); i++;
00124
00125 parsers.add ("h", i);
00126 parsers.add ("he", i);
00127 parsers.add ("hel", i);
00128 parsers.add ("help", i);
00129 pv.push_back (&ArgParser::do_help); i++;
00130
00131 parsers.add ("l", i);
00132 parsers.add ("lo", i);
00133 parsers.add ("loc", i);
00134 parsers.add ("lock", i);
00135 pv.push_back (&ArgParser::do_lock); i++;
00136
00137 parsers.add ("re", i);
00138 parsers.add ("rem", i);
00139 parsers.add ("remo", i);
00140 parsers.add ("remov", i);
00141 parsers.add ("remove", i);
00142 pv.push_back (&ArgParser::do_remove); i++;
00143
00144 parsers.add ("run", i);
00145 pv.push_back (&ArgParser::do_run); i++;
00146
00147 parsers.add ("run_sequence", i);
00148 pv.push_back (&ArgParser::do_run_sequence); i++;
00149
00150 parsers.add ("set", i);
00151 pv.push_back (&ArgParser::do_set); i++;
00152
00153 parsers.add ("setup", i);
00154 pv.push_back (&ArgParser::do_setup); i++;
00155
00156 parsers.add ("sh", i);
00157 parsers.add ("sho", i);
00158 parsers.add ("show", i);
00159 pv.push_back (&ArgParser::do_show); i++;
00160
00161 parsers.add ("sy", i);
00162 parsers.add ("sys", i);
00163 parsers.add ("syst", i);
00164 parsers.add ("syste", i);
00165 parsers.add ("system", i);
00166 pv.push_back (&ArgParser::do_system); i++;
00167
00168 parsers.add ("u", i);
00169 parsers.add ("un", i);
00170 parsers.add ("unl", i);
00171 parsers.add ("unlo", i);
00172 parsers.add ("unloc", i);
00173 parsers.add ("unlock", i);
00174 pv.push_back (&ArgParser::do_unlock); i++;
00175
00176 parsers.add ("v", i);
00177 parsers.add ("ve", i);
00178 parsers.add ("ver", i);
00179 parsers.add ("vers", i);
00180 parsers.add ("versi", i);
00181 parsers.add ("versio", i);
00182 parsers.add ("version", i);
00183 parsers.add ("--version", i);
00184 pv.push_back (&ArgParser::do_version); i++;
00185
00186 parsers.add ("-b", i);
00187 parsers.add ("-ba", i);
00188 parsers.add ("-bat", i);
00189 pv.push_back (&ArgParser::option_bat); i++;
00190
00191 parsers.add ("-c", i);
00192 parsers.add ("-cs", i);
00193 parsers.add ("-csh", i);
00194 pv.push_back (&ArgParser::option_csh); i++;
00195
00196 parsers.add ("-e", i);
00197 pv.push_back (&ArgParser::option_e); i++;
00198
00199 parsers.add ("-f", i);
00200 pv.push_back (&ArgParser::option_f); i++;
00201
00202 parsers.add ("-h", i);
00203 parsers.add ("-he", i);
00204 parsers.add ("-hel", i);
00205 parsers.add ("-help", i);
00206 parsers.add ("--h", i);
00207 parsers.add ("--he", i);
00208 parsers.add ("--hel", i);
00209 parsers.add ("--help", i);
00210 pv.push_back (&ArgParser::option_help); i++;
00211
00212 parsers.add ("-ho", i);
00213 parsers.add ("-hom", i);
00214 parsers.add ("-home", i);
00215 pv.push_back (&ArgParser::option_home); i++;
00216
00217 parsers.add ("-n", i);
00218 pv.push_back (&ArgParser::option_n); i++;
00219
00220 parsers.add ("-no_c", i);
00221 parsers.add ("-no_cl", i);
00222 parsers.add ("-no_cle", i);
00223 parsers.add ("-no_clea", i);
00224 parsers.add ("-no_clean", i);
00225 parsers.add ("-no_cleanu", i);
00226 parsers.add ("-no_cleanup", i);
00227 pv.push_back (&ArgParser::option_no_cleanup); i++;
00228
00229 parsers.add ("-pac", i);
00230 parsers.add ("-pack", i);
00231 pv.push_back (&ArgParser::option_pack); i++;
00232
00233 parsers.add ("-pat", i);
00234 parsers.add ("-path", i);
00235 pv.push_back (&ArgParser::option_path); i++;
00236
00237 parsers.add ("-pr", i);
00238 parsers.add ("-pri", i);
00239 parsers.add ("-priv", i);
00240 parsers.add ("-priva", i);
00241 parsers.add ("-privat", i);
00242 parsers.add ("-private", i);
00243 pv.push_back (&ArgParser::option_private); i++;
00244
00245 parsers.add ("-pu", i);
00246 parsers.add ("-pub", i);
00247 parsers.add ("-publ", i);
00248 parsers.add ("-publi", i);
00249 parsers.add ("-public", i);
00250 pv.push_back (&ArgParser::option_public); i++;
00251
00252 parsers.add ("-s", i);
00253 parsers.add ("-sh", i);
00254 pv.push_back (&ArgParser::option_sh); i++;
00255
00256 parsers.add ("-q", i);
00257 parsers.add ("-qu", i);
00258 parsers.add ("-qui", i);
00259 parsers.add ("-quie", i);
00260 parsers.add ("-quiet", i);
00261 pv.push_back (&ArgParser::option_quiet); i++;
00262
00263 parsers.add ("-tag", i);
00264 pv.push_back (&ArgParser::option_tag); i++;
00265
00266 parsers.add ("-tag_add", i);
00267 pv.push_back (&ArgParser::option_tag_add); i++;
00268
00269 parsers.add ("-tag_remove", i);
00270 pv.push_back (&ArgParser::option_tag_remove); i++;
00271
00272 parsers.add ("-u", i);
00273 parsers.add ("-us", i);
00274 parsers.add ("-use", i);
00275 pv.push_back (&ArgParser::option_use); i++;
00276
00277 parsers.add ("-user", i);
00278 parsers.add ("-user_", i);
00279 parsers.add ("-user_c", i);
00280 parsers.add ("-user_co", i);
00281 parsers.add ("-user_con", i);
00282 parsers.add ("-user_cont", i);
00283 parsers.add ("-user_conte", i);
00284 parsers.add ("-user_contex", i);
00285 parsers.add ("-user_context", i);
00286 pv.push_back (&ArgParser::option_user_context); i++;
00287
00288 parsers.add ("-v", i);
00289 parsers.add ("-ve", i);
00290 parsers.add ("-ver", i);
00291 parsers.add ("-vers", i);
00292 parsers.add ("-versi", i);
00293 parsers.add ("-versio", i);
00294 parsers.add ("-version", i);
00295 pv.push_back (&ArgParser::option_version); i++;
00296
00297 parsers.add ("-with_v", i);
00298 parsers.add ("-with_ve", i);
00299 parsers.add ("-with_ver", i);
00300 parsers.add ("-with_vers", i);
00301 parsers.add ("-with_versi", i);
00302 parsers.add ("-with_versio", i);
00303 parsers.add ("-with_version", i);
00304 parsers.add ("-with_version_", i);
00305 parsers.add ("-with_version_d", i);
00306 parsers.add ("-with_version_di", i);
00307 parsers.add ("-with_version_dir", i);
00308 parsers.add ("-with_version_dire", i);
00309 parsers.add ("-with_version_direc", i);
00310 parsers.add ("-with_version_direct", i);
00311 parsers.add ("-with_version_directo", i);
00312 parsers.add ("-with_version_director", i);
00313 parsers.add ("-with_version_directory", i);
00314 pv.push_back (&ArgParser::option_with_version_directory); i++;
00315
00316 parsers.add ("-without_v", i);
00317 parsers.add ("-without_ve", i);
00318 parsers.add ("-without_ver", i);
00319 parsers.add ("-without_vers", i);
00320 parsers.add ("-without_versi", i);
00321 parsers.add ("-without_versio", i);
00322 parsers.add ("-without_version", i);
00323 parsers.add ("-without_version_", i);
00324 parsers.add ("-without_version_d", i);
00325 parsers.add ("-without_version_di", i);
00326 parsers.add ("-without_version_dir", i);
00327 parsers.add ("-without_version_dire", i);
00328 parsers.add ("-without_version_direc", i);
00329 parsers.add ("-without_version_direct", i);
00330 parsers.add ("-without_version_directo", i);
00331 parsers.add ("-without_version_director", i);
00332 parsers.add ("-without_version_directory", i);
00333 pv.push_back (&ArgParser::option_without_version_directory); i++;
00334
00335 }
00336
00337 void ArgParser::shift ()
00338 {
00339 if (argc > 0)
00340 {
00341 argc--;
00342 argv++;
00343 }
00344 }
00345
00346 void ArgParser::unshift ()
00347 {
00348 argc++;
00349 argv--;
00350 }
00351
00352 void ArgParser::fill_arguments ()
00353 {
00354 while (argc > 0)
00355 {
00356 cmt_string& s = arguments.add ();
00357 s = argv[0];
00358
00359
00360
00361 shift ();
00362 }
00363 }
00364
00365 cmt_string& ArgParser::fill_one_argument ()
00366 {
00367 if (argc > 0)
00368 {
00369 cmt_string& s = arguments.add ();
00370 s = argv[0];
00371
00372
00373
00374 shift ();
00375
00376 return (s);
00377 }
00378 else
00379 {
00380 static cmt_string empty = "";
00381 return (empty);
00382 }
00383 }
00384
00385 cmt_string& ArgParser::fill_one_argument_filtered ()
00386 {
00387 if (argc > 0)
00388 {
00389 cmt_string& s = arguments.add ();
00390 s = argv[0];
00391
00392 if (s[0] == '-')
00393 {
00394 s = "";
00395 }
00396
00397
00398
00399 shift ();
00400
00401 return (s);
00402 }
00403 else
00404 {
00405 static cmt_string empty = "";
00406 return (empty);
00407 }
00408 }
00409
00410 void ArgParser::parse ()
00411 {
00412 ArgParser& me = *this;
00413
00414 help_action = action_none;
00415 arguments.clear ();
00416 extra_line.erase (0);
00417 extra_file.erase (0);
00418 mode = Csh;
00419
00421 shift ();
00422
00423 cmt.m_action = action_none;
00424
00425 while (argc > 0)
00426 {
00427 arg = argv[0];
00428
00429 shift ();
00430
00432 int cr = arg.find ('\r');
00433 if (cr != cmt_string::npos) arg.erase (cr);
00434
00436 if ((arg[0] == '\"') && (arg[arg.size () - 1] == '\"'))
00437 {
00438 arg.erase (0, 1);
00439 arg.erase (arg.size () - 1, 1);
00440 }
00441
00444 cmt_string reduced_arg = arg;
00445 int pos = reduced_arg.find ('=');
00446 if (pos != cmt_string::npos)
00447 {
00448 reduced_arg.erase (pos);
00449 arg.erase (0, pos+1);
00450 }
00451 else
00452 {
00453 arg = "";
00454 }
00455
00456
00457
00458 if (parsers.has (reduced_arg))
00459 {
00460
00461
00462 int i = (*parsers.find (reduced_arg));
00463
00464 parser p = pv[i];
00465 (me.*p) ();
00466 }
00467 else if (cmt.m_action != action_none)
00468 {
00469
00470
00471 if (!cmt.m_quiet) cerr << "#CMT> warning : unexpected parameter " << reduced_arg << endl;
00472 }
00473 else
00474 {
00475
00476
00477
00478 unshift ();
00479 do_do ();
00480
00481
00482
00483
00484
00485 }
00486 }
00487 }
00488
00489 void ArgParser::do_awk ()
00490 {
00491 fill_arguments ();
00492 cmt.m_action = action_awk;
00493 }
00494
00495 void ArgParser::do_broadcast ()
00496 {
00497 fill_arguments ();
00498 cmt.m_action = action_broadcast;
00499
00500 if (cmt.m_scope_filtering_mode == default_filtering_mode)
00501 {
00502 cmt.m_scope_filtering_mode = reach_private_uses;
00503 }
00504 }
00505
00506 void ArgParser::do_build ()
00507 {
00508 if (argc > 0)
00509 {
00510 arg = argv[0];
00511
00512 if (arg == "-nmake")
00513 {
00514 cmt.m_build_nmake = true;
00515 shift ();
00516 }
00517 }
00518
00519 if (argc > 0)
00520 {
00521 arg = argv[0];
00522
00523 shift ();
00524
00525 if (arg == "constituent_makefile")
00526 {
00527 if (argc > 0)
00528 {
00529 fill_one_argument ();
00530 cmt.m_action = action_build_constituent_makefile;
00531 }
00532 else
00533 {
00534 if (!cmt.m_quiet) cerr << "#CMT> syntax error : constituent name missing" << endl;
00535 cmt.m_action = action_build_constituent_makefile;
00536 help_action = action_help;
00537 }
00538 }
00539 else if (arg == "constituents_makefile")
00540 {
00541 fill_arguments ();
00542 cmt.m_action = action_build_constituents_makefile;
00543 }
00544 else if (arg == "dependencies")
00545 {
00546 if (argc > 0)
00547 {
00548 fill_arguments ();
00549 cmt.m_action = action_build_dependencies;
00550 }
00551 else
00552 {
00553 if (!cmt.m_quiet) cerr << "#CMT> syntax error : arguments missing " << endl;
00554 help_action = action_help;
00555 cmt.m_action = action_build_dependencies;
00556 }
00557 }
00558 else if (arg == "library_links")
00559 {
00560 cmt.m_action = action_build_library_links;
00561 }
00562 else if (arg == "make_setup")
00563 {
00564 cmt.m_action = action_build_make_setup;
00565 }
00566 else if (arg == "msdev")
00567 {
00568 if (argc > 0)
00569 {
00570 fill_one_argument_filtered ();
00571 }
00572
00573 cmt.m_action = action_build_msdev;
00574 }
00575 else if (arg == "CMT_pacman")
00576 {
00577 cmt.m_action = action_build_CMT_pacman;
00578 }
00579 else if (arg == "vsnet")
00580 {
00581 if (argc > 0)
00582 {
00583 fill_one_argument_filtered ();
00584 }
00585
00586 cmt.m_action = action_build_vsnet;
00587 }
00588 else if (arg == "os9_makefile")
00589 {
00590 if (argc > 0)
00591 {
00592 fill_one_argument ();
00593 cmt.m_action = action_build_os9_makefile;
00594 }
00595 else
00596 {
00597 if (!cmt.m_quiet) cerr << "#CMT> syntax error : arguments missing " << endl;
00598 help_action = action_help;
00599 cmt.m_action = action_build_os9_makefile;
00600 }
00601 }
00602 else if (arg == "prototype")
00603 {
00604 if (argc > 0)
00605 {
00606 fill_one_argument ();
00607 cmt.m_action = action_build_prototype;
00608 }
00609 else
00610 {
00611 if (!cmt.m_quiet) cerr << "#CMT> syntax error : arguments missing" << endl;
00612 help_action = action_help;
00613 cmt.m_action = action_build_prototype;
00614 }
00615 }
00616 else if (arg == "readme")
00617 {
00618 cmt.m_action = action_build_readme;
00619
00620 fill_arguments ();
00621 }
00622 else if (arg == "tag_makefile")
00623 {
00624 cmt.m_action = action_build_tag_makefile;
00625 }
00626 else if (arg == "temporary_name")
00627 {
00628 cmt.m_action = action_build_temporary_name;
00629 }
00630 else if (arg == "triggers")
00631 {
00632 if (argc > 0)
00633 {
00634 fill_one_argument ();
00635 cmt.m_action = action_build_triggers;
00636 }
00637 else
00638 {
00639 if (!cmt.m_quiet) cerr << "#CMT> syntax error : arguments missing" << endl;
00640 help_action = action_help;
00641 cmt.m_action = action_build_triggers;
00642 }
00643 }
00644 else if (arg == "windefs")
00645 {
00646 if (argc > 0)
00647 {
00648 fill_one_argument ();
00649 cmt.m_action = action_build_windefs;
00650 }
00651 else
00652 {
00653 if (!cmt.m_quiet) cerr << "#CMT> syntax error : arguments missing" << endl;
00654 help_action = action_help;
00655 cmt.m_action = action_build_windefs;
00656 }
00657 }
00658 else
00659 {
00660 if (!cmt.m_quiet) cerr << "#CMT> syntax error : wrong build argument" << endl;
00661 help_action = action_help;
00662 cmt.m_action = action_build;
00663 }
00664 }
00665 else
00666 {
00667 if (!cmt.m_quiet) cerr << "#CMT> syntax error : don't know what to build" << endl;
00668 help_action = action_help;
00669 cmt.m_action = action_build;
00670 }
00671 }
00672
00673 void ArgParser::do_check ()
00674 {
00675 if (argc > 0)
00676 {
00677 arg = argv[0];
00678
00679 shift ();
00680
00681 if (arg == "configuration")
00682 {
00683 cmt.m_action = action_check_configuration;
00684 }
00685 else if (arg == "files")
00686 {
00687 if (argc > 0)
00688 {
00689 fill_one_argument ();
00690 if (argc > 0)
00691 {
00692 fill_one_argument ();
00693 cmt.m_action = action_check_files;
00694 }
00695 else
00696 {
00697 if (!cmt.m_quiet) cerr << "#CMT> syntax error : reference file name missing"
00698 << endl;
00699 help_action = action_help;
00700 cmt.m_action = action_check_files;
00701 }
00702 }
00703 else
00704 {
00705 if (!cmt.m_quiet) cerr << "#CMT> syntax error : file name missing" << endl;
00706 help_action = action_help;
00707 cmt.m_action = action_check_files;
00708 }
00709 }
00710 else if (arg == "version")
00711 {
00712 if (argc > 0)
00713 {
00714 fill_one_argument ();
00715 cmt.m_action = action_check_version;
00716 }
00717 else
00718 {
00719 if (!cmt.m_quiet) cerr << "#CMT> syntax error : package name missing" << endl;
00720 help_action = action_help;
00721 cmt.m_action = action_check_version;
00722 }
00723 }
00724 else
00725 {
00726 if (!cmt.m_quiet) cerr << "#CMT> syntax error : bad check option" << endl;
00727 help_action = action_help;
00728 cmt.m_action = action_check;
00729 }
00730 }
00731 else
00732 {
00733 if (!cmt.m_quiet) cerr << "#CMT> syntax error : don't know what to check" << endl;
00734 help_action = action_help;
00735 cmt.m_action = action_check;
00736 }
00737 }
00738
00739 void ArgParser::do_check_files ()
00740 {
00741 if (argc > 0)
00742 {
00743 fill_one_argument ();
00744 if (argc > 0)
00745 {
00746 fill_one_argument ();
00747 cmt.m_action = action_check_files;
00748 }
00749 else
00750 {
00751 if (!cmt.m_quiet) cerr << "#CMT> syntax error : reference file missing" << endl;
00752 help_action = action_help;
00753 cmt.m_action = action_check_files;
00754 }
00755 }
00756 else
00757 {
00758 if (!cmt.m_quiet) cerr << "#CMT> syntax error : file name missing" << endl;
00759 help_action = action_help;
00760 cmt.m_action = action_check_files;
00761 }
00762 }
00763
00764 void ArgParser::do_checkout ()
00765 {
00766 if (argc > 0)
00767 {
00768 fill_arguments ();
00769 cmt.m_action = action_checkout;
00770 }
00771 else
00772 {
00773 if (!cmt.m_quiet) cerr << "#CMT> syntax error : checkout arguments missing" << endl;
00774 help_action = action_help;
00775 cmt.m_action = action_checkout;
00776 }
00777 }
00778
00779 void ArgParser::do_cleanup ()
00780 {
00781 cmt.m_action = action_cleanup;
00782 }
00783
00784 void ArgParser::do_config ()
00785 {
00786 cmt.m_action = action_config;
00787 }
00788
00789 void ArgParser::do_create ()
00790 {
00791 if (argc > 0)
00792 {
00793 fill_arguments ();
00794 cmt.m_action = action_create;
00795 }
00796 else
00797 {
00798 if (!cmt.m_quiet) cerr << "#CMT> syntax error : create arguments missing" << endl;
00799 help_action = action_help;
00800 cmt.m_action = action_create;
00801 }
00802 }
00803
00804 void ArgParser::do_create_project ()
00805 {
00806 if (argc > 0)
00807 {
00808 fill_arguments ();
00809 cmt.m_action = action_create_project;
00810 }
00811 else
00812 {
00813 if (!cmt.m_quiet) cerr << "#CMT> syntax error : create_project arguments missing" << endl;
00814 help_action = action_help;
00815 cmt.m_action = action_create_project;
00816 }
00817 }
00818
00819 void ArgParser::do_cvsbranches ()
00820 {
00821 if (argc > 0)
00822 {
00823 fill_one_argument ();
00824 cmt.m_action = action_cvsbranches;
00825 }
00826 else
00827 {
00828 if (!cmt.m_quiet) cerr << "#CMT> syntax error : cvsbranches arguments missing" << endl;
00829 help_action = action_help;
00830 cmt.m_action = action_cvsbranches;
00831 }
00832 }
00833
00834 void ArgParser::do_cvssubpackages ()
00835 {
00836 if (argc > 0)
00837 {
00838 fill_one_argument ();
00839 }
00840
00841 cmt.m_action = action_cvssubpackages;
00842 }
00843
00844 void ArgParser::do_cvssubprojects ()
00845 {
00846 if (argc > 0)
00847 {
00848 fill_one_argument ();
00849 }
00850
00851 cmt.m_action = action_cvssubprojects;
00852 }
00853
00854 void ArgParser::do_cvstags ()
00855 {
00856 if (argc > 0)
00857 {
00858 fill_arguments ();
00859 cmt.m_action = action_cvstags;
00860 }
00861 else
00862 {
00863 if (!cmt.m_quiet) cerr << "#CMT> syntax error : package name missing" << endl;
00864 help_action = action_help;
00865 cmt.m_action = action_cvstags;
00866 }
00867 }
00868
00869 void ArgParser::do_do ()
00870 {
00871 if (argc > 0)
00872 {
00873 fill_arguments ();
00874
00875 {
00876 cmt_string tag_name = "target_";
00877 tag_name += arguments[0];
00878
00879 Tag* tag;
00880 tag = Tag::add (tag_name, PriorityUserTag, "action", 0);
00881 tag->mark ();
00882 }
00883
00884 cmt.m_action = action_do;
00885 }
00886 else
00887 {
00888 if (!cmt.m_quiet) cerr << "#CMT> syntax error : action not specified" << endl;
00889 help_action = action_help;
00890 cmt.m_action = action_do;
00891 }
00892 }
00893
00894 void ArgParser::do_expand ()
00895 {
00896 if (argc > 0)
00897 {
00898 arg = argv[0];
00899
00900 shift ();
00901 if (arg == "model")
00902 {
00903 if (argc > 0)
00904 {
00905 fill_arguments ();
00906 cmt.m_action = action_expand_model;
00907 }
00908 else
00909 {
00910 if (!cmt.m_quiet) cerr << "#CMT> syntax error : model not specified" << endl;
00911 help_action = action_help;
00912 cmt.m_action = action_expand_model;
00913 }
00914 }
00915 else
00916 {
00917 if (!cmt.m_quiet) cerr << "#CMT> syntax error : bad expand option" << endl;
00918 help_action = action_help;
00919 cmt.m_action = action_expand_model;
00920 }
00921 }
00922 else
00923 {
00924 if (!cmt.m_quiet) cerr << "#CMT> syntax error : don't know what to expand" << endl;
00925 help_action = action_help;
00926 cmt.m_action = action_expand_model;
00927 }
00928 }
00929
00930 void ArgParser::do_filter ()
00931 {
00932 if (argc > 0)
00933 {
00934 fill_arguments ();
00935 cmt.m_action = action_filter;
00936 }
00937 else
00938 {
00939 if (!cmt.m_quiet) cerr << "#CMT> syntax error : file to filter not specified" << endl;
00940 help_action = action_help;
00941 cmt.m_action = action_filter;
00942 }
00943 }
00944
00945 void ArgParser::do_help ()
00946 {
00947 help_action = action_help;
00948 }
00949
00950 void ArgParser::do_lock ()
00951 {
00952 if (argc > 0)
00953 {
00954 cmt.m_current_package = fill_one_argument ();
00955 cmt.m_current_version.erase (0);
00956 cmt.m_current_path.erase (0);
00957
00958 if (argc > 0)
00959 {
00960 cmt.m_current_version = fill_one_argument ();
00961 cmt.m_action = action_lock;
00962
00963 if (argc > 0)
00964 {
00965 cmt.m_current_path = fill_one_argument_filtered ();
00966 }
00967
00968 cmt.m_current_access = UserMode;
00969 (Use::current()).set (cmt.m_current_package,
00970 cmt.m_current_version,
00971 cmt.m_current_path);
00972
00973 }
00974 else
00975 {
00976 if (!cmt.m_quiet) cerr << "#CMT> syntax error : version missing" << endl;
00977 help_action = action_help;
00978 cmt.m_action = action_lock;
00979 }
00980 }
00981 else
00982 {
00983 cmt.m_action = action_lock;
00984 }
00985 }
00986
00987 void ArgParser::do_remove ()
00988 {
00989 if (argc > 0)
00990 {
00991 arg = argv[0];
00992
00993 if (arg == "library_links")
00994 {
00995 shift ();
00996 cmt.m_action = action_remove_library_links;
00997 }
00998 else
00999 {
01000 cmt.m_current_package = fill_one_argument ();
01001 cmt.m_current_version.erase (0);
01002 cmt.m_current_path.erase (0);
01003
01004 if (argc > 0)
01005 {
01006 cmt.m_current_version = fill_one_argument ();
01007
01008 if (argc > 0)
01009 {
01010 cmt.m_current_path = fill_one_argument_filtered ();
01011 }
01012
01013 cmt.m_action = action_remove;
01014 }
01015 else
01016 {
01017 if (!cmt.m_quiet) cerr << "#CMT> syntax error : version missing" << endl;
01018 help_action = action_help;
01019 cmt.m_action = action_remove;
01020 }
01021 }
01022 }
01023 else
01024 {
01025 if (!cmt.m_quiet) cerr << "#CMT> syntax error : don't know what to remove" << endl;
01026 help_action = action_help;
01027 cmt.m_action = action_remove;
01028 }
01029 }
01030
01031 void ArgParser::do_run ()
01032 {
01033 if (argc > 0)
01034 {
01035 fill_arguments ();
01036 cmt.m_action = action_run;
01037 }
01038 else
01039 {
01040 if (!cmt.m_quiet) cerr << "#CMT> syntax error : run arguments missing" << endl;
01041 help_action = action_help;
01042 cmt.m_action = action_run;
01043 }
01044 }
01045
01046 void ArgParser::do_run_sequence ()
01047 {
01048 if (argc > 0)
01049 {
01050 fill_one_argument ();
01051 cmt.m_action = action_run_sequence;
01052 }
01053 else
01054 {
01055 if (!cmt.m_quiet) cerr << "#CMT> syntax error : run_sequence arguments missing" << endl;
01056 help_action = action_help;
01057 cmt.m_action = action_run_sequence;
01058 }
01059 }
01060
01061 void ArgParser::do_set ()
01062 {
01063 if (argc > 0)
01064 {
01065 arg = argv[0];
01066
01067 shift ();
01068
01069 if (arg == "version")
01070 {
01071 fill_arguments ();
01072 cmt.m_action = action_set_version;
01073 }
01074 else if (arg == "versions")
01075 {
01076 fill_arguments ();
01077
01078 cmt.m_action = action_set_versions;
01079
01080 if (cmt.m_scope_filtering_mode == default_filtering_mode)
01081 {
01082 cmt.m_scope_filtering_mode = reach_private_uses;
01083 }
01084 }
01085 else
01086 {
01087 if (!cmt.m_quiet) cerr << "#CMT> syntax error : bad set argument" << endl;
01088 help_action = action_help;
01089
01090 }
01091 }
01092 else
01093 {
01094 if (!cmt.m_quiet) cerr << "#CMT> syntax error : don't know what to set" << endl;
01095 help_action = action_help;
01096
01097 }
01098 }
01099
01100 void ArgParser::do_setup ()
01101 {
01102 cmt.m_action = action_setup;
01103 }
01104
01105 void ArgParser::do_show ()
01106 {
01107 if (argc > 0)
01108 {
01109 arg = argv[0];
01110
01111
01112
01113 shift ();
01114
01115 if (arg == "action")
01116 {
01117 if (argc > 0)
01118 {
01119 cmt.m_current_target = fill_one_argument ();
01120 cmt.m_action = action_show_action;
01121 }
01122 else
01123 {
01124 if (!cmt.m_quiet) cerr << "#CMT> syntax error : action name missing" << endl;
01125 help_action = action_help;
01126 cmt.m_action = action_show_action;
01127 }
01128 }
01129 else if (arg == "action_names")
01130 {
01131 if (argc > 0)
01132 {
01133 fill_one_argument ();
01134 }
01135
01136 cmt.m_action = action_show_action_names;
01137 }
01138 else if (arg == "action_value")
01139 {
01140 cmt.m_quiet = true;
01141 if (argc > 0)
01142 {
01143 cmt.m_current_target = fill_one_argument ();
01144 cmt.m_action = action_show_action_value;
01145 }
01146 else
01147 {
01148 if (!cmt.m_quiet) cerr << "#CMT> syntax error : action name missing" << endl;
01149 help_action = action_help;
01150 cmt.m_action = action_show_action_value;
01151 }
01152 }
01153 else if (arg == "actions")
01154 {
01155 if (argc > 0)
01156 {
01157 fill_one_argument ();
01158 }
01159
01160 cmt.m_action = action_show_actions;
01161 }
01162 else if (arg == "all_tags")
01163 {
01164 cmt.m_action = action_show_all_tags;
01165 }
01166 else if (arg == "applied_patterns")
01167 {
01168 cmt.m_action = action_show_applied_patterns;
01169 }
01170 else if (arg == "author")
01171 {
01172 cmt.m_action = action_show_author;
01173 }
01174 else if (arg == "branches")
01175 {
01176 cmt.m_action = action_show_branches;
01177 }
01178 else if (arg == "clients")
01179 {
01180 if (argc > 0)
01181 {
01182 cmt.m_current_target = fill_one_argument ();
01183
01184 cmt.m_action = action_show_clients;
01185
01186 if (argc > 0)
01187 {
01188 fill_one_argument ();
01189 if (argc > 0)
01190 {
01191 fill_one_argument ();
01192 }
01193 }
01194 }
01195 else
01196 {
01197 if (!cmt.m_quiet) cerr << "#CMT> syntax error : package name missing" << endl;
01198 help_action = action_help;
01199 cmt.m_action = action_show_clients;
01200 }
01201 }
01202 else if (arg == "cmtpath_patterns")
01203 {
01204 cmt.m_action = action_show_cmtpath_patterns;
01205 }
01206 else if (arg == "constituent")
01207 {
01208 if (argc > 0)
01209 {
01210 cmt.m_current_target = fill_one_argument ();
01211 cmt.m_action = action_show_constituent;
01212 }
01213 else
01214 {
01215 if (!cmt.m_quiet) cerr << "#CMT> syntax error : constituent name missing" << endl;
01216 help_action = action_help;
01217 cmt.m_action = action_show_constituent;
01218 }
01219 }
01220 else if (arg == "constituent_names")
01221 {
01222 cmt.m_action = action_show_constituent_names;
01223 }
01224 else if (arg == "constituents")
01225 {
01226 cmt.m_action = action_show_constituents;
01227 }
01228 else if (arg == "cycles")
01229 {
01230 cmt.m_action = action_show_cycles;
01231 }
01232 else if (arg == "fragment")
01233 {
01234 if (argc > 0)
01235 {
01236 cmt.m_current_target = fill_one_argument ();
01237 cmt.m_action = action_show_fragment;
01238 }
01239 else
01240 {
01241 if (!cmt.m_quiet) cerr << "#CMT> syntax error : fragment name missing" << endl;
01242 help_action = action_help;
01243 cmt.m_action = action_show_fragment;
01244 }
01245 }
01246 else if (arg == "fragments")
01247 {
01248 cmt.m_action = action_show_fragments;
01249 }
01250 else if (arg == "groups")
01251 {
01252 cmt.m_action = action_show_groups;
01253 }
01254 else if (arg == "include_dirs")
01255 {
01256 cmt.m_action = action_show_include_dirs;
01257 }
01258 else if (arg == "language")
01259 {
01260 if (argc > 0)
01261 {
01262 cmt.m_current_target = fill_one_argument ();
01263 cmt.m_action = action_show_language;
01264 }
01265 else
01266 {
01267 if (!cmt.m_quiet) cerr << "#CMT> syntax error : language name missing" << endl;
01268 help_action = action_help;
01269 cmt.m_action = action_show_language;
01270 }
01271 }
01272 else if (arg == "languages")
01273 {
01274 cmt.m_action = action_show_languages;
01275 }
01276 else if (arg == "macro")
01277 {
01278 if (argc > 0)
01279 {
01280 cmt.m_current_target = fill_one_argument ();
01281 cmt.m_action = action_show_macro;
01282 }
01283 else
01284 {
01285 if (!cmt.m_quiet) cerr << "#CMT> syntax error : macro name missing" << endl;
01286 help_action = action_help;
01287 cmt.m_action = action_show_macro;
01288 }
01289 }
01290 else if (arg == "macro_names")
01291 {
01292 if (argc > 0)
01293 {
01294 fill_one_argument ();
01295 }
01296
01297 cmt.m_action = action_show_macro_names;
01298 }
01299 else if (arg == "macro_value")
01300 {
01301 cmt.m_quiet = true;
01302 if (argc > 0)
01303 {
01304 cmt.m_current_target = fill_one_argument ();
01305 cmt.m_action = action_show_macro_value;
01306 }
01307 else
01308 {
01309 if (!cmt.m_quiet) cerr << "#CMT> syntax error : macro name missing" << endl;
01310 help_action = action_help;
01311 cmt.m_action = action_show_macro_value;
01312 }
01313 }
01314 else if (arg == "macros")
01315 {
01316 if (argc > 0)
01317 {
01318 fill_one_argument ();
01319 }
01320
01321 cmt.m_action = action_show_macros;
01322 }
01323 else if (arg == "manager")
01324 {
01325 cmt.m_action = action_show_manager;
01326 }
01327 else if (arg == "packages")
01328 {
01329 if (argc > 0)
01330 {
01331 cmt.m_current_target = fill_one_argument ();
01332 }
01333
01334 cmt.m_action = action_show_packages;
01335 }
01336 else if (arg == "path")
01337 {
01338 cmt.m_action = action_show_path;
01339 }
01340 else if (arg == "pattern")
01341 {
01342 if (argc > 0)
01343 {
01344 cmt.m_current_target = fill_one_argument ();
01345 cmt.m_action = action_show_pattern;
01346 }
01347 else
01348 {
01349 if (!cmt.m_quiet) cerr << "#CMT> syntax error : pattern name missing" << endl;
01350 help_action = action_help;
01351 cmt.m_action = action_show_pattern;
01352 }
01353 }
01354 else if (arg == "pattern_names")
01355 {
01356 cmt.m_action = action_show_pattern_names;
01357 }
01358 else if (arg == "patterns")
01359 {
01360 cmt.m_action = action_show_patterns;
01361 }
01362 else if (arg == "projects")
01363 {
01364 cmt.m_action = action_show_projects;
01365 }
01366 else if (arg == "pwd")
01367 {
01368 cmt.m_action = action_show_pwd;
01369 }
01370 else if (arg == "setup")
01371 {
01372 cmt.m_action = action_show_setup;
01373
01374 if (cmt.m_scope_filtering_mode == default_filtering_mode)
01375 {
01376 cmt.m_scope_filtering_mode = reach_private_uses;
01377 }
01378 }
01379 else if (arg == "set_names")
01380 {
01381 if (argc > 0)
01382 {
01383 fill_one_argument ();
01384 }
01385
01386 cmt.m_action = action_show_set_names;
01387 }
01388 else if (arg == "set_value")
01389 {
01390 cmt.m_quiet = true;
01391 if (argc > 0)
01392 {
01393 cmt.m_current_target = fill_one_argument ();
01394 cmt.m_action = action_show_set_value;
01395 }
01396 else
01397 {
01398 if (!cmt.m_quiet) cerr << "#CMT> syntax error : set name missing" << endl;
01399 help_action = action_help;
01400 cmt.m_action = action_show_set_value;
01401 }
01402 }
01403 else if (arg == "set")
01404 {
01405 if (argc > 0)
01406 {
01407 cmt.m_current_target = fill_one_argument ();
01408 cmt.m_action = action_show_set;
01409 }
01410 else
01411 {
01412 if (!cmt.m_quiet) cerr << "#CMT> syntax error : set name missing" << endl;
01413 help_action = action_help;
01414 cmt.m_action = action_show_set;
01415 }
01416 }
01417 else if (arg == "sets")
01418 {
01419 if (argc > 0)
01420 {
01421 fill_one_argument ();
01422 }
01423
01424 cmt.m_action = action_show_sets;
01425 }
01426 else if (arg == "strategies")
01427 {
01428 cmt.m_action = action_show_strategies;
01429 }
01430 else if (arg == "tags")
01431 {
01432 cmt.m_action = action_show_tags;
01433 }
01434 else if (arg == "use_paths")
01435 {
01436 if (argc > 0)
01437 {
01438 while (argc > 0)
01439 {
01440 if (strcmp (argv[0], "-private") == 0)
01441 {
01442 cmt.m_scope_filtering_mode = reach_private_uses;
01443 }
01444 else if (strcmp (argv[0], "--private") == 0)
01445 {
01446 cmt.m_scope_filtering_mode = reach_private_uses;
01447 }
01448 else
01449 {
01450 cmt_string& s = arguments.add ();
01451 s = argv[0];
01452 }
01453
01454 shift ();
01455 }
01456
01457 cmt.m_action = action_show_use_paths;
01458 }
01459 else
01460 {
01461 if (!cmt.m_quiet) cerr << "#CMT> syntax error : package name missing" << endl;
01462 help_action = action_help;
01463 cmt.m_action = action_show_use_paths;
01464 }
01465 }
01466 else if ((arg == "u") ||
01467 (arg == "us") ||
01468 (arg == "use") ||
01469 (arg == "uses"))
01470 {
01471 cmt.m_action = action_show_uses;
01472
01473 if (cmt.m_scope_filtering_mode == default_filtering_mode)
01474 {
01475 cmt.m_scope_filtering_mode = reach_private_uses;
01476 }
01477 }
01478 else if (arg == "version")
01479 {
01480 cmt.m_action = action_show_version;
01481 }
01482 else if (arg == "versions")
01483 {
01484 if (argc > 0)
01485 {
01486 cmt.m_current_target = fill_one_argument ();
01487 cmt.m_action = action_show_versions;
01488 }
01489 else
01490 {
01491 if (!cmt.m_quiet) cerr << "#CMT> syntax error : package name missing" << endl;
01492 help_action = action_help;
01493 cmt.m_action = action_show_versions;
01494 }
01495 }
01496 else
01497 {
01498 if (!cmt.m_quiet) cerr << "#CMT> syntax error : bad show argument" << endl;
01499 help_action = action_help;
01500 cmt.m_action = action_show;
01501 }
01502 }
01503 else
01504 {
01505 if (!cmt.m_quiet) cerr << "#CMT> syntax error : don't know what to show" << endl;
01506 help_action = action_help;
01507 cmt.m_action = action_show;
01508 }
01509 }
01510
01511 void ArgParser::do_system ()
01512 {
01513 cmt.m_action = action_system;
01514 }
01515
01516 void ArgParser::do_unlock ()
01517 {
01518 if (argc > 0)
01519 {
01520 cmt.m_current_package = fill_one_argument ();
01521 cmt.m_current_version.erase (0);
01522 cmt.m_current_path.erase (0);
01523
01524 if (argc > 0)
01525 {
01526 cmt.m_current_version = fill_one_argument ();
01527 cmt.m_action = action_unlock;
01528
01529 if (argc > 0)
01530 {
01531 cmt.m_current_path = fill_one_argument_filtered ();
01532 }
01533
01534 cmt.m_current_access = UserMode;
01535 (Use::current()).set (cmt.m_current_package,
01536 cmt.m_current_version,
01537 cmt.m_current_path);
01538
01539 }
01540 else
01541 {
01542 if (!cmt.m_quiet) cerr << "#CMT> syntax error : version missing" << endl;
01543 help_action = action_help;
01544 cmt.m_action = action_unlock;
01545 }
01546 }
01547 else
01548 {
01549 cmt.m_action = action_unlock;
01550 }
01551 }
01552
01553 void ArgParser::do_version ()
01554 {
01555 cmt.m_action = action_version;
01556 }
01557
01558 void ArgParser::option_help ()
01559 {
01560 help_action = action_help;
01561 }
01562
01563 void ArgParser::option_n ()
01564 {
01565 cmt.m_simulation = true;
01566 }
01567
01568 void ArgParser::option_quiet ()
01569 {
01570 cmt.m_quiet = true;
01571 }
01572
01573 void ArgParser::option_csh ()
01574 {
01575 mode = Csh;
01576 }
01577
01578 void ArgParser::option_sh ()
01579 {
01580 mode = Sh;
01581 }
01582
01583 void ArgParser::option_bat ()
01584 {
01585 mode = Bat;
01586 }
01587
01588 void ArgParser::option_use ()
01589 {
01590 if (cmt.m_action != action_create)
01591 {
01592 CmtSystem::cmt_string_vector words;
01593
01594 CmtSystem::split (arg, ":", words);
01595
01596 cmt.m_current_access = UserMode;
01597
01598 if (words.size () > 0) cmt.m_current_package = words[0];
01599 if (words.size () > 1) cmt.m_current_version = words[1];
01600 if (words.size () > 2) cmt.m_current_path = words[2];
01601 (Use::current()).set (cmt.m_current_package,
01602 cmt.m_current_version,
01603 cmt.m_current_path);
01604 }
01605 }
01606
01607 void ArgParser::option_pack ()
01608 {
01609 if ((cmt.m_action != action_create) && (cmt.m_current_package != arg))
01610 {
01611
01612
01613 cmt.m_current_access = UserMode;
01614
01615 cmt.m_current_package = arg;
01616 cmt.m_current_version = "";
01617
01618
01619
01620
01621
01622
01623
01624
01625 (Use::current()).set (cmt.m_current_package,
01626 cmt.m_current_version,
01627 cmt.m_current_path);
01628 }
01629 }
01630
01631 void ArgParser::option_version ()
01632 {
01633 if ((cmt.m_action != action_create) && (cmt.m_current_version != arg))
01634 {
01635 cmt.m_current_access = UserMode;
01636 cmt.m_current_version = arg;
01637
01638
01639
01640
01641
01642
01643
01644
01645 (Use::current()).set (cmt.m_current_package,
01646 cmt.m_current_version,
01647 cmt.m_current_path);
01648 }
01649 }
01650
01651 void ArgParser::option_path ()
01652 {
01653 if ((cmt.m_action != action_create) && (cmt.m_current_path != arg))
01654 {
01655 cmt.m_current_access = UserMode;
01656 cmt.m_current_path = arg;
01657
01658
01659
01660
01661
01662
01663
01664
01665 (Use::current()).set (cmt.m_current_package,
01666 cmt.m_current_version,
01667 cmt.m_current_path);
01668
01669
01670
01671 }
01672 }
01673
01674 void ArgParser::option_f ()
01675 {
01676 extra_file = arg;
01677 }
01678
01679 void ArgParser::option_e ()
01680 {
01681 cerr << "#CMT> Warning: extra statement = " << arg << endl;
01682 extra_line = arg;
01683 }
01684
01685 void ArgParser::option_home ()
01686 {
01687 if (CmtSystem::test_directory (arg))
01688 {
01689 cmt.m_cmt_home = arg;
01690 }
01691 }
01692
01693 void ArgParser::option_tag ()
01694 {
01695
01696
01697
01698
01699 if (arg != "")
01700 {
01701 Tag* tag;
01702 CmtSystem::cmt_string_vector words;
01703
01704
01705
01706 Tag::unmark_all ();
01707 cmt.m_extra_tags = ",";
01708
01709
01710 Cmt::configure_version_tag ();
01711 Cmt::configure_site_tag (0);
01712 Cmt::configure_uname_tag ();
01713 Cmt::configure_hosttype_tag ();
01714 Cmt::configure_config_tag ();
01715 Cmt::configure_home (0);
01716 Cmt::guess_current_project ();
01717
01718 CmtSystem::split (arg, " \t,", words);
01719
01720 for (int i = 0; i < words.size (); i++)
01721 {
01722 const cmt_string& a = words[i];
01723
01724 cmt_string s = ",";
01725 s += a;
01726 s += ",";
01727
01728 if (i == 0)
01729 {
01730 cmt.m_current_tag = a;
01731
01732 if (CmtSystem::testenv ("TAGDEBUG")) cerr
01733 << "parse_argument(tag_add)> current_tag=" << cmt.m_current_tag << endl;
01734 }
01735
01736 if (cmt.m_extra_tags.find (s) == cmt_string::npos)
01737 {
01738
01739
01740
01741 if (a == CmtSystem::get_cmt_config ())
01742 {
01743 Cmt::configure_uname_tag ();
01744 }
01745
01746 tag = Tag::add (a, PriorityArgument, "arguments", 0);
01747
01748 tag->mark ();
01749
01750 cmt.m_extra_tags += a;
01751 cmt.m_extra_tags += ",";
01752 }
01753 }
01754 }
01755 }
01756
01757 void ArgParser::option_tag_add ()
01758 {
01759 Tag* tag;
01760 CmtSystem::cmt_string_vector words;
01761
01762
01763
01764 CmtSystem::split (arg, " \t,", words);
01765
01766 for (int i = 0; i < words.size (); i++)
01767 {
01768 const cmt_string& a = words[i];
01769
01770 cmt_string s = ",";
01771 s += a;
01772 s += ",";
01773
01774 if (cmt.m_extra_tags.find (s) == cmt_string::npos)
01775 {
01776
01777
01779 if (a == CmtSystem::get_cmt_config ())
01780 {
01781 Cmt::configure_uname_tag ();
01782 }
01783
01784 tag = Tag::add (a, PriorityUserTag, "arguments", 0);
01785
01786 tag->mark ();
01787
01788 cmt.m_extra_tags += a;
01789 cmt.m_extra_tags += ",";
01790 }
01791 }
01792 }
01793
01794 void ArgParser::option_tag_remove ()
01795 {
01796 Tag::TagPtrVector tags = Tag::tags ();
01797 int i;
01798 Tag* tag;
01799
01800
01801
01802
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812 CmtSystem::cmt_string_vector words;
01813
01814
01815
01816 CmtSystem::split (arg, " \t,", words);
01817
01818
01819
01820
01821
01822
01823 for (i = 0; i < words.size (); i++)
01824 {
01825 const cmt_string& a = words[i];
01826
01827 cmt_string s = ",";
01828 s += a;
01829 s += ",";
01830
01831 int pos;
01832
01833 pos = cmt.m_extra_tags.find (s);
01834
01835 if (pos != cmt_string::npos)
01836 {
01837 cmt.m_extra_tags.erase (pos, s.size () - 1);
01838 }
01839
01840
01841 }
01842
01843
01844
01845
01846
01847
01849 Tag::unmark_all ();
01850
01852 Cmt::configure_version_tag ();
01853 Cmt::configure_site_tag (0);
01854 Cmt::configure_uname_tag ();
01855 Cmt::configure_hosttype_tag ();
01856
01857 CmtSystem::split (cmt.m_extra_tags, " \t,", words);
01858
01859 for (i = 0; i < words.size (); i++)
01860 {
01861 const cmt_string& a = words[i];
01862
01863
01864
01866 if (a == CmtSystem::get_cmt_config ())
01867 {
01868 Cmt::configure_uname_tag ();
01869 }
01870
01871 if (i == 0)
01872 {
01873 cmt.m_current_tag = a;
01874
01875
01876
01877
01878 tag = Tag::add (a, PriorityTag, "restore configuration", 0);
01879 }
01880 else
01881 {
01882 tag = Tag::add (a, PriorityUserTag, "restore configuration", 0);
01883 }
01884
01885 tag->mark ();
01886 }
01887 }
01888
01889 void ArgParser::option_user_context ()
01890 {
01891 if (CmtSystem::test_directory (arg))
01892 {
01893 cmt.m_cmt_user_context = arg;
01894 }
01895 }
01896
01897 void ArgParser::option_with_version_directory ()
01898 {
01899 cmt.m_current_structuring_style = with_version_directory;
01900 }
01901
01902 void ArgParser::option_without_version_directory ()
01903 {
01904 cmt.m_current_structuring_style = without_version_directory;
01905 }
01906
01907 void ArgParser::option_no_cleanup ()
01908 {
01909
01910 }
01911
01912 void ArgParser::option_private ()
01913 {
01914 cmt.m_scope_filtering_mode = reach_private_uses;
01915 }
01916
01917 void ArgParser::option_public ()
01918 {
01919 cmt.m_scope_filtering_mode = block_private_uses;
01920 }
01921
01922
01923
01924
01925
01926
01927 CommandHelp::HelpMap& CommandHelp::get_help ()
01928 {
01929 static CommandHelp& me = instance ();
01930
01931 return (me.m_help);
01932 }
01933
01934 CommandHelp::HelpTexts& CommandHelp::get_help_texts ()
01935 {
01936 static CommandHelp& me = instance ();
01937
01938 return (me.m_help_texts);
01939 }
01940
01941 const cmt_string& CommandHelp::get_help_text (ActionType key)
01942 {
01943 static const HelpTexts& help = get_help_texts ();
01944
01945 const cmt_string& h = help[key];
01946 return (h);
01947 }
01948
01949 void CommandHelp::show_all ()
01950 {
01951 static HelpTexts& help_texts = get_help_texts ();
01952
01953 cerr << "#> cmt command [option...]" << endl;
01954 cerr << "# command :" << endl;
01955
01956 int i;
01957
01958 for (i = 0; ; i++)
01959 {
01960 const cmt_string& s = help_texts[i];
01961 if (s == "") break;
01962 cerr << "# " << s << endl;
01963 }
01964
01965 cerr << "# global options :" << endl;
01966
01967 cerr << "# -quiet : don't print errors" << endl;
01968 cerr << "# -use=<p>:<v>:<path> : set package version path" << endl;
01969 cerr << "# -pack=<package> : set package" << endl;
01970 cerr << "# -version=<version> : set version" << endl;
01971 cerr << "# -path=<path> : set root path" << endl;
01972 cerr << "# -f=<requirement-file> : set input file" << endl;
01973 cerr << "# -e=<statement> : add a one line statement" << endl;
01974 cerr << "# -tag=<tag-list> : select a new tag-set" << endl;
01975 cerr << "# -tag_add=<tag-list> : add specific comma-separated tag(s)" << endl;
01976 cerr << "# -tag_remove=<tag-list> : remove specific comma-separated tag(s)" << endl;
01977 cerr << "# -with_version_directory : reset to default structuring style" << endl;
01978 cerr << "# -without_version_directory : switch structuring style" << endl;
01979 cerr << "# -cleanup : activate install area cleanup" << endl;
01980 cerr << "# -no_cleanup : inhibit install area cleanup" << endl;
01981 }
01982
01983 void CommandHelp::show (ActionType action)
01984 {
01985
01986
01987 static HelpTexts& help_texts = get_help_texts ();
01988
01989 if (action == action_build)
01990 {
01991 int i;
01992
01993 for (i = action_build_constituent_makefile; i <= action_build_windefs; i++)
01994 {
01995 const cmt_string& s = help_texts[i];
01996 cerr << "# " << s << endl;
01997 }
01998 }
01999 if (action == action_check)
02000 {
02001 int i;
02002
02003 for (i = action_check_configuration; i <= action_check_version; i++)
02004 {
02005 const cmt_string& s = help_texts[i];
02006 cerr << "# " << s << endl;
02007 }
02008 }
02009 else if (action == action_show)
02010 {
02011 int i;
02012
02013 for (i = (action_show + 1); i <= action_show_versions; i++)
02014 {
02015 const cmt_string& s = help_texts[i];
02016 cerr << "# " << s << endl;
02017 }
02018 }
02019 else
02020 {
02021 const cmt_string& s = get_help_text (action);
02022 cerr << "#" << s << endl;
02023 }
02024 }
02025
02026 CommandHelp& CommandHelp::instance ()
02027 {
02028 static CommandHelp me;
02029 return (me);
02030 }
02031
02032 CommandHelp::CommandHelp ()
02033 {
02034 static HelpMap& help = m_help;
02035
02036 static HelpTexts& help_texts = m_help_texts;
02037
02038 help_texts.clear ();
02039
02040 help_texts.add () = "none";
02041 help_texts.add () = "awk";
02042 help_texts.add () = "broadcast [-select=list] [-exclude=list] [-local] [-global] [-begin=pattern] [-depth=n] <command> : apply a command to [some of] the used packages";
02043 help_texts.add () = "build <option> : build actions. (Try cmt help build)";
02044 help_texts.add () = "build constituent_makefile <constituent> : generate constituent Makefile fragment";
02045 help_texts.add () = "build constituents_makefile : generate constituents.make";
02046 help_texts.add () = "build dependencies : generate dependencies";
02047 help_texts.add () = "build library_links : build symbolic links towards all imported libraries";
02048 help_texts.add () = "build make_setup : build a compiled version of setup scripts";
02049 help_texts.add () = "build msdev : generate MSDEV files";
02050 help_texts.add () = "build CMT_pacman : generate PACMAN manifest file for CMT";
02051 help_texts.add () = "build vsnet : generate VS.NET files";
02052 help_texts.add () = "build os9_makefile : generate Makefile for OS9";
02053 help_texts.add () = "build prototype : generate prototype file";
02054 help_texts.add () = "build readme : generate README.html";
02055 help_texts.add () = "build tag_makefile : generate tag specific Makefile";
02056 help_texts.add () = "build temporary_name : generate a name for a temprary file";
02057 help_texts.add () = "build triggers <constituent> : generate library trigger file";
02058 help_texts.add () = "build windefs <library_name> : generate def file for Windows shared libraries";
02059 help_texts.add () = "check <option> : check actions. (Try cmt help check)";
02060 help_texts.add () = "check configuration : check configuration";
02061 help_texts.add () = "check files <old> <new> : compare two files and overrides <old> by <new> if different";
02062 help_texts.add () = "check version <name> : check if a name follows a version tag syntax ";
02063 help_texts.add () = "co | checkout : perform a cvs checkout over a CMT package";
02064 help_texts.add () = "cleanup [-csh|-sh|-bat] : generate a cleanup script";
02065 help_texts.add () = "config : generate setup and cleanup scripts";
02066 help_texts.add () = "create <package> <version> [<path>] : create and configure a new package";
02067 help_texts.add () = "create_project <project> <name> [<path>] : create and configure a new project";
02068 help_texts.add () = "cvsbranches <module> : display the subdirectories for a module";
02069 help_texts.add () = "cvssubpackages <module> : display the subpackages for a module";
02070 help_texts.add () = "cvssubprojects <module> : display the subprojects for a module";
02071 help_texts.add () = "cvstags <module> : display the CVS tags for a module";
02072 help_texts.add () = "do <action> [<param>=<value>] ... : Execute an action";
02073 help_texts.add () = "expand model <model> : ";
02074 help_texts.add () = "filter <in> <out> : filter a file against CMT macros and env. variables";
02075 help_texts.add () = "help | -help | --help : display this help";
02076 help_texts.add () = "load";
02077 help_texts.add () = "lock [<p> <v> [<path>]] : lock a package";
02078 help_texts.add () = "remove <package> <version> [<path>] : remove a package version";
02079 help_texts.add () = "remove library_links : remove symbolic links towards all imported libraries";
02080 help_texts.add () = "run '<command>' : apply a command";
02081 help_texts.add () = "run_sequence <sequence file> : execute a cmt equence file";
02082 help_texts.add () = "set version <version> : generate a version file in the current package";
02083 help_texts.add () = "set versions : generate version files into packages";
02084 help_texts.add () = "setup [-csh|-sh|-bat] : generate a setup script";
02085 help_texts.add () = "show <option> : query actions. (Try cmt help show)";
02086 help_texts.add () = "show action <name> : a formatted action definition";
02087 help_texts.add () = "show action_value <name> : a raw action definition";
02088 help_texts.add () = "show action_names : all action names";
02089 help_texts.add () = "show actions : all action definitions";
02090 help_texts.add () = "show all_tags : all defined tags";
02091 help_texts.add () = "show applied_patterns : all patterns actually applied";
02092 help_texts.add () = "show author : package author";
02093 help_texts.add () = "show branches : added branches";
02094 help_texts.add () = "show clients : package clients";
02095 help_texts.add () = "show cmtpath_patterns : cmtpath_patterns";
02096 help_texts.add () = "show constituent <name>: constituent definition";
02097 help_texts.add () = "show constituent_names : constituent names";
02098 help_texts.add () = "show constituents : constituent definitions";
02099 help_texts.add () = "show cycles : cycles in the use graph";
02100 help_texts.add () = "show fragment <name> : one fragment definition";
02101 help_texts.add () = "show fragments : fragment definitions";
02102 help_texts.add () = "show groups : group definitions";
02103 help_texts.add () = "show include_dirs : ";
02104 help_texts.add () = "show language <name> : language definition";
02105 help_texts.add () = "show languages : language definitions";
02106 help_texts.add () = "show macro <name> : a formatted macro definition";
02107 help_texts.add () = "show macro_value <name> : a raw macro definition";
02108 help_texts.add () = "show macro_names : all macro names";
02109 help_texts.add () = "show macros : all macro definitions";
02110 help_texts.add () = "show manager : package manager";
02111 help_texts.add () = "show packages : packages reachable from the current context";
02112 help_texts.add () = "show path : the package search list";
02113 help_texts.add () = "show pattern <name> : the pattern definition and usages";
02114 help_texts.add () = "show pattern_names : pattern names";
02115 help_texts.add () = "show patterns : the pattern definitions";
02116 help_texts.add () = "show projects : project definitions";
02117 help_texts.add () = "show setup : setup definitions";
02118 help_texts.add () = "show pwd : filtered current directory";
02119 help_texts.add () = "show set <name> : a formatted set definition";
02120 help_texts.add () = "show set_names : set names";
02121 help_texts.add () = "show set_value <name> : a raw set definition";
02122 help_texts.add () = "show sets : set definitions";
02123 help_texts.add () = "show strategies : all strategies (build & version)";
02124 help_texts.add () = "show tags : all currently active tags";
02125 help_texts.add () = "show use_paths <pack> : all paths to the used package";
02126 help_texts.add () = "show uses : used packages";
02127 help_texts.add () = "show version : version of the current package";
02128 help_texts.add () = "show versions <name> : visible versions of the selected package";
02129 help_texts.add () = "system : display the system tag";
02130 help_texts.add () = "unlock [<p> <v> [<path>]] : unlock a package";
02131 help_texts.add () = "version : version of CMT";
02132 help_texts.add () = "";
02133
02134
02135
02136
02137 help.add (action_none, help_texts[action_none]);
02138 help.add (action_awk, help_texts[action_awk]);
02139 help.add (action_broadcast, help_texts[action_broadcast]);
02140 help.add (action_build, help_texts[action_build]);
02141 help.add (action_build_constituent_makefile, help_texts[action_build_constituent_makefile]);
02142 help.add (action_build_constituents_makefile, help_texts[action_build_constituents_makefile]);
02143 help.add (action_build_dependencies, help_texts[action_build_dependencies]);
02144 help.add (action_build_library_links, help_texts[action_build_library_links]);
02145 help.add (action_build_make_setup, help_texts[action_build_make_setup]);
02146 help.add (action_build_msdev, help_texts[action_build_msdev]);
02147 help.add (action_build_CMT_pacman, help_texts[action_build_CMT_pacman]);
02148 help.add (action_build_vsnet, help_texts[action_build_vsnet]);
02149 help.add (action_build_os9_makefile, help_texts[action_build_os9_makefile]);
02150 help.add (action_build_prototype, help_texts[action_build_prototype]);
02151 help.add (action_build_readme, help_texts[action_build_readme]);
02152 help.add (action_build_tag_makefile, help_texts[action_build_tag_makefile]);
02153 help.add (action_build_temporary_name, help_texts[action_build_temporary_name]);
02154 help.add (action_build_triggers, help_texts[action_build_triggers]);
02155 help.add (action_build_windefs, help_texts[action_build_windefs]);
02156 help.add (action_check_configuration, help_texts[action_check_configuration]);
02157 help.add (action_check_files, help_texts[action_check_files]);
02158 help.add (action_check_version, help_texts[action_check_version]);
02159 help.add (action_checkout, help_texts[action_checkout]);
02160 help.add (action_cleanup, help_texts[action_cleanup]);
02161 help.add (action_config, help_texts[action_config]);
02162 help.add (action_create, help_texts[action_create]);
02163 help.add (action_create_project, help_texts[action_create_project]);
02164 help.add (action_cvsbranches, help_texts[action_cvsbranches]);
02165 help.add (action_cvssubpackages, help_texts[action_cvssubpackages]);
02166 help.add (action_cvssubprojects, help_texts[action_cvssubprojects]);
02167 help.add (action_cvstags, help_texts[action_cvstags]);
02168 help.add (action_do, help_texts[action_do]);
02169 help.add (action_expand_model, help_texts[action_expand_model]);
02170 help.add (action_filter, help_texts[action_filter]);
02171 help.add (action_help, help_texts[action_help]);
02172 help.add (action_load, help_texts[action_load]);
02173 help.add (action_lock, help_texts[action_lock]);
02174 help.add (action_remove, help_texts[action_remove]);
02175 help.add (action_remove_library_links, help_texts[action_remove_library_links]);
02176 help.add (action_run, help_texts[action_run]);
02177 help.add (action_run_sequence, help_texts[action_run_sequence]);
02178 help.add (action_set_version, help_texts[action_set_version]);
02179 help.add (action_set_versions, help_texts[action_set_versions]);
02180 help.add (action_setup, help_texts[action_setup]);
02181 help.add (action_show, help_texts[action_show]);
02182 help.add (action_show_action, help_texts[action_show_action]);
02183 help.add (action_show_action_value, help_texts[action_show_action_value]);
02184 help.add (action_show_action_names, help_texts[action_show_action_names]);
02185 help.add (action_show_actions, help_texts[action_show_actions]);
02186 help.add (action_show_all_tags, help_texts[action_show_all_tags]);
02187 help.add (action_show_applied_patterns, help_texts[action_show_applied_patterns]);
02188 help.add (action_show_author, help_texts[action_show_author]);
02189 help.add (action_show_branches, help_texts[action_show_branches]);
02190 help.add (action_show_clients, help_texts[action_show_clients]);
02191 help.add (action_show_cmtpath_patterns, help_texts[action_show_cmtpath_patterns]);
02192 help.add (action_show_constituent, help_texts[action_show_constituent]);
02193 help.add (action_show_constituent_names, help_texts[action_show_constituent_names]);
02194 help.add (action_show_constituents, help_texts[action_show_constituents]);
02195 help.add (action_show_cycles, help_texts[action_show_cycles]);
02196 help.add (action_show_fragment, help_texts[action_show_fragment]);
02197 help.add (action_show_fragments, help_texts[action_show_fragments]);
02198 help.add (action_show_groups, help_texts[action_show_groups]);
02199 help.add (action_show_include_dirs, help_texts[action_show_include_dirs]);
02200 help.add (action_show_language, help_texts[action_show_language]);
02201 help.add (action_show_languages, help_texts[action_show_languages]);
02202 help.add (action_show_macro, help_texts[action_show_macro]);
02203 help.add (action_show_macro_value, help_texts[action_show_macro_value]);
02204 help.add (action_show_macro_names, help_texts[action_show_macro_names]);
02205 help.add (action_show_macros, help_texts[action_show_macros]);
02206 help.add (action_show_manager, help_texts[action_show_manager]);
02207 help.add (action_show_packages, help_texts[action_show_packages]);
02208 help.add (action_show_path, help_texts[action_show_path]);
02209 help.add (action_show_pattern, help_texts[action_show_pattern]);
02210 help.add (action_show_pattern_names, help_texts[action_show_pattern_names]);
02211 help.add (action_show_patterns, help_texts[action_show_patterns]);
02212 help.add (action_show_projects, help_texts[action_show_projects]);
02213 help.add (action_show_setup, help_texts[action_show_setup]);
02214 help.add (action_show_pwd, help_texts[action_show_pwd]);
02215 help.add (action_show_set, help_texts[action_show_set]);
02216 help.add (action_show_set_names, help_texts[action_show_set_names]);
02217 help.add (action_show_set_value, help_texts[action_show_set_value]);
02218 help.add (action_show_sets, help_texts[action_show_sets]);
02219 help.add (action_show_strategies, help_texts[action_show_strategies]);
02220 help.add (action_show_tags, help_texts[action_show_tags]);
02221 help.add (action_show_use_paths, help_texts[action_show_use_paths]);
02222 help.add (action_show_uses, help_texts[action_show_uses]);
02223 help.add (action_show_version, help_texts[action_show_version]);
02224 help.add (action_show_versions, help_texts[action_show_versions]);
02225 help.add (action_system, help_texts[action_system]);
02226 help.add (action_unlock, help_texts[action_unlock]);
02227 help.add (action_version, help_texts[action_version]);
02228 }
02229