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