monotone

monotone Mtn Source Tree

Root/options_list.hh

1// Copyright 2006 Timothy Brownawell <tbrownaw@gmail.com>
2// This is made available under the GNU GPL v2 or later.
3
4/*
5 * This is a list of all options that monotone can take, what variables
6 * they get put into, and how they get there. There are 4 important macros
7 * available here (and only here):
8 *
9 * OPTSET(name)
10 * Defines a set of related options, which can easily be allowed for
11 * a particular command or reset together. It is named
12 * 'options::opts::name'.
13 *
14 * OPTSET_REL(parent, child)
15 * Declare a relationship between two optsets, so that if the parent
16 * is reset or allowed for a command the child will also be.
17 *
18 * OPTVAR(optset, type, name, default)
19 * Defines a variable 'type options::name' which is initialized to
20 * 'type (default)' and belongs to the named optset. When the optset
21 * is reset, this variable will be reset to 'type (default)'.
22 *
23 * OPTION(optset, name, hasarg, optstring, description)
24 * Declare an option named 'options::opts::name', which belongs to the
25 * given optset. 'optstring' can look like "foo", in which case it is
26 * specified as "--foo", or it can look like "foo,f", in which case it
27 * is specified as either "--foo" or "-f". The description is a
28 * translatable help text. 'hasarg' is a bool indicating whether this
29 * option takes an argument.
30 *
31 * Some expansions of this macro expect a function body, which looks
32 * like 'void (std::string const & arg)'. This is the 'setter' function
33 * for this option, and is called when the option is parsed. If the
34 * option was declared to not take an argument, 'arg' is empty.
35 * Otherwise, it is the given argument. In any case this function
36 * should set the option variables for this option and throw a
37 * 'bad_arg_internal' if this fails. The variables that are set must be
38 * part of the same optset as the option, or they won't get reset
39 * properly. When the function body is needed, 'option_bodies' will
40 * be defined.
41 */
42
43// This is a shortcut for an option which has its own variable and optset.
44// It will take an argument unless 'type' is 'bool'.
45#define OPT(name, string, type, default_, description) \
46 OPTVAR(name, type, name, default_)\
47 OPTION(name, name, has_arg<type >(), string, description)
48
49// This is the same, except that the option and variable belong to the
50// 'globals' optset. These are global options, not specific to a particular
51// command.
52#define GOPT(name, string, type, default_, description)\
53 OPTVAR(globals, type, name, default_)\
54 OPTION(globals, name, has_arg<type >(), string, description)
55
56OPTSET(globals)
57
58OPTVAR(globals, args_vector, args, )
59OPTION(globals, positionals, true, "--", "")
60#ifdef option_bodies
61{
62 args.push_back(arg_type(arg));
63}
64#endif
65
66OPT(author, "author", utf8, , gettext_noop("override author for commit"))
67#ifdef option_bodies
68{
69 author = utf8(arg);
70}
71#endif
72
73OPT(automate_stdio_size, "automate-stdio-size", size_t, 32768,
74 gettext_noop("block size in bytes for \"automate stdio\" output"))
75#ifdef option_bodies
76{
77 automate_stdio_size = boost::lexical_cast<long>(arg);
78 if (automate_stdio_size <= 0)
79 throw bad_arg_internal(F("cannot be zero or negative").str());
80}
81#endif
82
83OPTSET(bind_opts)
84OPTVAR(bind_opts, std::list<utf8>, bind_uris, )
85OPTVAR(bind_opts, bool, bind_stdio, false)
86OPTVAR(bind_opts, bool, use_transport_auth, true)
87
88OPTION(bind_opts, bind, true, "bind",
89 gettext_noop("address:port to listen on (default :4691)"))
90#ifdef option_bodies
91{
92 bind_uris.push_back(utf8(arg));
93 bind_stdio = false;
94}
95#endif
96OPTION(bind_opts, no_transport_auth, false, "no-transport-auth",
97 gettext_noop("disable transport authentication"))
98#ifdef option_bodies
99{
100 use_transport_auth = false;
101}
102#endif
103OPTION(bind_opts, bind_stdio, false, "stdio",
104 gettext_noop("serve netsync on stdio"))
105#ifdef option_bodies
106{
107 bind_stdio = true;
108}
109#endif
110
111OPTVAR(branch, branch_name, branchname, )
112OPTION(branch, branch, true, "branch,b",
113 gettext_noop("select branch cert for operation"))
114#ifdef option_bodies
115{
116 branchname = branch_name(arg);
117}
118#endif
119
120OPT(brief, "brief", bool, false,
121 gettext_noop("print a brief version of the normal output"))
122#ifdef option_bodies
123{
124 brief = true;
125}
126#endif
127
128OPT(revs_only, "revs-only", bool, false,
129 gettext_noop("annotate using full revision ids only"))
130#ifdef option_bodies
131{
132 revs_only = true;
133}
134#endif
135
136GOPT(conf_dir, "confdir", system_path, get_default_confdir(),
137 gettext_noop("set location of configuration directory"))
138#ifdef option_bodies
139{
140 conf_dir = system_path(arg);
141 if (!key_dir_given)
142 key_dir = (conf_dir / "keys");
143}
144#endif
145
146GOPT(no_default_confdir, "no-default-confdir", bool, false,
147 gettext_noop("forbid use of the default confdir"))
148#ifdef option_bodies
149{
150 no_default_confdir = true;
151}
152#endif
153
154OPT(date, "date", date_t, ,
155 gettext_noop("override date/time for commit"))
156#ifdef option_bodies
157{
158 try
159 {
160 date = date_t::from_string(arg);
161 }
162 catch (std::exception &e)
163 {
164 throw bad_arg_internal(e.what());
165 }
166}
167#endif
168
169GOPT(dbname, "db,d", system_path, , gettext_noop("set name of database"))
170#ifdef option_bodies
171{
172 dbname = system_path(arg);
173}
174#endif
175
176OPTION(globals, debug, false, "debug",
177 gettext_noop("print debug log to stderr while running"))
178#ifdef option_bodies
179{
180 global_sanity.set_debug();
181}
182#endif
183
184OPT(depth, "depth", long, -1,
185 gettext_noop("limit the number of levels of directories to descend"))
186#ifdef option_bodies
187{
188 depth = boost::lexical_cast<long>(arg);
189 if (depth < 0)
190 throw bad_arg_internal(F("cannot be negative").str());
191}
192#endif
193
194
195OPTSET(diff_options)
196
197OPTVAR(diff_options, std::string, external_diff_args, )
198OPTION(diff_options, external_diff_args, true, "diff-args",
199 gettext_noop("argument to pass external diff hook"))
200#ifdef option_bodies
201{
202 external_diff_args = arg;
203}
204#endif
205
206OPTVAR(diff_options, diff_type, diff_format, unified_diff)
207OPTION(diff_options, diff_context, false, "context",
208 gettext_noop("use context diff format"))
209#ifdef option_bodies
210{
211 diff_format = context_diff;
212}
213#endif
214OPTION(diff_options, diff_external, false, "external",
215 gettext_noop("use external diff hook for generating diffs"))
216#ifdef option_bodies
217{
218 diff_format = external_diff;
219}
220#endif
221OPTION(diff_options, diff_unified, false, "unified",
222 gettext_noop("use unified diff format"))
223#ifdef option_bodies
224{
225 diff_format = unified_diff;
226}
227#endif
228OPTVAR(diff_options, bool, no_show_encloser, false)
229OPTION(diff_options, no_show_encloser, false, "no-show-encloser",
230 gettext_noop("do not show the function containing each block of changes"))
231#ifdef option_bodies
232{
233 no_show_encloser = true;
234}
235#endif
236
237OPTVAR(diff_options, bool, without_header, false);
238OPTVAR(diff_options, bool, with_header, false);
239OPTION(diff_options, without_header, false, "without-header",
240 gettext_noop("show the matching cset in the diff header"))
241#ifdef option_bodies
242{
243 with_header = false;
244 without_header = true;
245}
246#endif
247OPTION(diff_options, with_header, false, "with-header",
248 gettext_noop("do not show the matching cset in the diff header"))
249#ifdef option_bodies
250{
251 with_header = true;
252 without_header = false;
253}
254#endif
255
256OPT(diffs, "diffs", bool, false, gettext_noop("print diffs along with logs"))
257#ifdef option_bodies
258{
259 diffs = true;
260}
261#endif
262
263OPTVAR(drop_attr, std::set<std::string>, attrs_to_drop, )
264OPTION(drop_attr, drop_attr, true, "drop-attr",
265 gettext_noop("when rosterifying, drop attrs entries with the given key"))
266#ifdef option_bodies
267{
268 attrs_to_drop.insert(arg);
269}
270#endif
271
272OPT(dryrun, "dry-run", bool, false,
273 gettext_noop("don't perform the operation, just show what would have happened"))
274#ifdef option_bodies
275{
276 dryrun = true;
277}
278#endif
279
280OPTION(globals, dump, true, "dump",
281 gettext_noop("file to dump debugging log to, on failure"))
282#ifdef option_bodies
283{
284 global_sanity.set_dump_path(system_path(arg).as_external());
285}
286#endif
287
288OPTVAR(exclude, args_vector, exclude_patterns, )
289OPTION(exclude, exclude, true, "exclude",
290 gettext_noop("leave out anything described by its argument"))
291#ifdef option_bodies
292{
293 exclude_patterns.push_back(arg_type(arg));
294}
295#endif
296
297OPT(bookkeep_only, "bookkeep-only", bool, false,
298 gettext_noop("only update monotone's internal bookkeeping, not the filesystem"))
299#ifdef option_bodies
300{
301 bookkeep_only = true;
302}
303#endif
304
305GOPT(ssh_sign, "ssh-sign", std::string, "yes",
306 gettext_noop("controls use of ssh-agent. valid arguments are: "
307 "'yes' to use ssh-agent to make signatures if possible, "
308 "'no' to force use of monotone's internal code, "
309 "'only' to force use of ssh-agent, "
310 "'check' to sign with both and compare"))
311#ifdef option_bodies
312{
313 if (arg.empty())
314 throw bad_arg_internal(F("--ssh-sign requires a value "
315 "['yes', 'no', 'only', or 'check']").str());
316 if (arg != "yes"
317 && arg != "no"
318 && arg != "check"
319 && arg != "only") // XXX what does "only" do? not documented
320 throw bad_arg_internal(F("--ssh-sign must be set to 'yes', 'no', "
321 "'only', or 'check'").str());
322
323 ssh_sign = arg;
324}
325#endif
326
327OPT(full, "full", bool, false,
328 gettext_noop("print detailed version number"))
329#ifdef option_bodies
330{
331 full = true;
332}
333#endif
334
335GOPT(help, "help,h", bool, false, gettext_noop("display help message"))
336#ifdef option_bodies
337{
338 help = true;
339}
340#endif
341
342OPTVAR(include, args_vector, include_patterns, )
343OPTION(include, include, true, "include",
344 gettext_noop("include anything described by its argument"))
345#ifdef option_bodies
346{
347 include_patterns.push_back(arg_type(arg));
348}
349#endif
350
351GOPT(ignore_suspend_certs, "ignore-suspend-certs", bool, false,
352 gettext_noop("do not ignore revisions marked as suspended"))
353#ifdef option_bodies
354{
355 ignore_suspend_certs = true;
356}
357#endif
358
359
360OPTVAR(key, rsa_keypair_id, signing_key, )
361OPTION(globals, key, true, "key,k", gettext_noop("set key for signatures"))
362#ifdef option_bodies
363{
364 internalize_rsa_keypair_id(utf8(arg), signing_key);
365}
366#endif
367
368GOPT(key_dir, "keydir", system_path, get_default_keydir(),
369 gettext_noop("set location of key store"))
370#ifdef option_bodies
371{
372 key_dir = system_path(arg);
373}
374#endif
375
376OPTVAR(key_to_push, std::vector<rsa_keypair_id>, keys_to_push, )
377OPTION(key_to_push, key_to_push, true, "key-to-push",
378 gettext_noop("push the specified key even if it hasn't signed anything"))
379#ifdef option_bodies
380{
381 rsa_keypair_id keyid;
382 internalize_rsa_keypair_id(utf8(arg), keyid);
383 keys_to_push.push_back(keyid);
384}
385#endif
386
387OPT(last, "last", long, -1,
388 gettext_noop("limit log output to the last number of entries"))
389#ifdef option_bodies
390{
391 last = boost::lexical_cast<long>(arg);
392 if (last <= 0)
393 throw bad_arg_internal(F("cannot be zero or negative").str());
394}
395#endif
396
397OPTION(globals, log, true, "log", gettext_noop("file to write the log to"))
398#ifdef option_bodies
399{
400 ui.redirect_log_to(system_path(arg));
401}
402#endif
403
404OPTSET(messages)
405OPTVAR(messages, std::vector<std::string>, message, )
406OPTVAR(messages, utf8, msgfile, )
407OPTION(messages, message, true, "message,m",
408 gettext_noop("set commit changelog message"))
409#ifdef option_bodies
410{
411 message.push_back(arg);
412}
413#endif
414OPTION(messages, msgfile, true, "message-file",
415 gettext_noop("set filename containing commit changelog message"))
416#ifdef option_bodies
417{
418 msgfile = utf8(arg);
419}
420#endif
421
422OPT(missing, "missing", bool, false,
423 gettext_noop("perform the operations for files missing from workspace"))
424#ifdef option_bodies
425{
426 missing = true;
427}
428#endif
429
430OPT(next, "next", long, -1,
431 gettext_noop("limit log output to the next number of entries"))
432#ifdef option_bodies
433{
434 next = boost::lexical_cast<long>(arg);
435 if (next <= 0)
436 throw bad_arg_internal(F("cannot be zero or negative").str());
437}
438#endif
439
440OPT(no_files, "no-files", bool, false,
441 gettext_noop("exclude files when printing logs"))
442#ifdef option_bodies
443{
444 no_files = true;
445}
446#endif
447
448OPT(no_graph, "no-graph", bool, false,
449 gettext_noop("do not use ASCII graph to display ancestry"))
450#ifdef option_bodies
451{
452 no_graph = true;
453}
454#endif
455
456OPT(no_ignore, "no-respect-ignore", bool, false,
457 gettext_noop("do not ignore any files"))
458#ifdef option_bodies
459{
460 no_ignore = true;
461}
462#endif
463
464OPT(no_merges, "no-merges", bool, false,
465 gettext_noop("exclude merges when printing logs"))
466#ifdef option_bodies
467{
468 no_merges = true;
469}
470#endif
471
472GOPT(norc, "norc", bool, false,
473gettext_noop("do not load ~/.monotone/monotonerc or _MTN/monotonerc lua files"))
474#ifdef option_bodies
475{
476 norc = true;
477}
478#endif
479
480GOPT(nostd, "nostd", bool, false,
481 gettext_noop("do not load standard lua hooks"))
482#ifdef option_bodies
483{
484 nostd = true;
485}
486#endif
487
488OPT(pidfile, "pid-file", system_path, ,
489 gettext_noop("record process id of server"))
490#ifdef option_bodies
491{
492 pidfile = system_path(arg);
493}
494#endif
495
496GOPT(quiet, "quiet", bool, false,
497 gettext_noop("suppress verbose, informational and progress messages"))
498#ifdef option_bodies
499{
500 quiet = true;
501 global_sanity.set_quiet();
502 ui.set_tick_write_nothing();
503}
504#endif
505
506GOPT(extra_rcfiles, "rcfile", args_vector, ,
507 gettext_noop("load extra rc file"))
508#ifdef option_bodies
509{
510 extra_rcfiles.push_back(arg_type(arg));
511}
512#endif
513
514GOPT(reallyquiet, "reallyquiet", bool, false,
515gettext_noop("suppress warning, verbose, informational and progress messages"))
516#ifdef option_bodies
517{
518 reallyquiet = true;
519 global_sanity.set_reallyquiet();
520 ui.set_tick_write_nothing();
521}
522#endif
523
524OPT(recursive, "recursive,R", bool, false,
525 gettext_noop("also operate on the contents of any listed directories"))
526#ifdef option_bodies
527{
528 recursive = true;
529}
530#endif
531
532OPTVAR(revision, args_vector, revision_selectors, )
533OPTION(revision, revision, true, "revision,r",
534 gettext_noop("select revision id for operation"))
535#ifdef option_bodies
536{
537 revision_selectors.push_back(arg_type(arg));
538}
539#endif
540
541GOPT(root, "root", std::string, ,
542 gettext_noop("limit search for workspace to specified root"))
543#ifdef option_bodies
544{
545 root = arg;
546}
547#endif
548
549GOPT(no_workspace, "no-workspace", bool, false,
550 gettext_noop("don't look for a workspace"))
551#ifdef option_bodies
552{
553 no_workspace = true;
554}
555#endif
556
557OPT(set_default, "set-default", bool, false,
558 gettext_noop("use the current arguments as the future default"))
559#ifdef option_bodies
560{
561 set_default = true;
562}
563#endif
564
565GOPT(ticker, "ticker", std::string, ,
566 gettext_noop("set ticker style (count|dot|none)"))
567#ifdef option_bodies
568{
569 ticker = arg;
570 if (ticker == "none" || global_sanity.quiet_p())
571 ui.set_tick_write_nothing();
572 else if (ticker == "dot")
573 ui.set_tick_write_dot();
574 else if (ticker == "count")
575 ui.set_tick_write_count();
576 else
577 throw bad_arg_internal(F("argument must be 'none', 'dot', or 'count'").str());
578}
579#endif
580
581OPT(from, "from", args_vector, , gettext_noop("revision(s) to start logging at"))
582#ifdef option_bodies
583{
584 from.push_back(arg_type(arg));
585}
586#endif
587
588OPT(to, "to", args_vector, , gettext_noop("revision(s) to stop logging at"))
589#ifdef option_bodies
590{
591 to.push_back(arg_type(arg));
592}
593#endif
594
595OPT(unknown, "unknown", bool, false,
596 gettext_noop("perform the operations for unknown files from workspace"))
597#ifdef option_bodies
598{
599 unknown = true;
600}
601
602#endif
603
604OPT(verbose, "verbose", bool, false,
605 gettext_noop("verbose completion output"))
606#ifdef option_bodies
607{
608 verbose = true;
609}
610#endif
611
612GOPT(version, "version", bool, false,
613 gettext_noop("print version number, then exit"))
614#ifdef option_bodies
615{
616 version = true;
617}
618#endif
619
620OPTION(globals, xargs, true, "xargs,@",
621 gettext_noop("insert command line arguments taken from the given file"))
622#ifdef option_bodies
623{
624}
625#endif
626
627OPTSET(automate_inventory_opts)
628OPTVAR(automate_inventory_opts, bool, no_ignored, false)
629OPTVAR(automate_inventory_opts, bool, no_unknown, false)
630OPTVAR(automate_inventory_opts, bool, no_unchanged, false)
631OPTVAR(automate_inventory_opts, bool, no_corresponding_renames, false)
632
633OPTION(automate_inventory_opts, no_ignored, false, "no-ignored",
634 gettext_noop("don't output ignored files"))
635#ifdef option_bodies
636{
637 no_ignored = true;
638}
639#endif
640
641OPTION(automate_inventory_opts, no_unknown, false, "no-unknown",
642 gettext_noop("don't output unknown files"))
643#ifdef option_bodies
644{
645 no_unknown = true;
646}
647#endif
648
649OPTION(automate_inventory_opts, no_unchanged, false, "no-unchanged",
650 gettext_noop("don't output unchanged files"))
651#ifdef option_bodies
652{
653 no_unchanged = true;
654}
655#endif
656
657OPTION(automate_inventory_opts, no_corresponding_renames, false, "no-corresponding-renames",
658 gettext_noop("don't output corresponding renames if restricted on such nodes"))
659#ifdef option_bodies
660{
661 no_corresponding_renames = true;
662}
663#endif
664
665// Local Variables:
666// mode: C++
667// fill-column: 76
668// c-file-style: "gnu"
669// indent-tabs-mode: nil
670// End:
671// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status