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 to 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
237OPT(diffs, "diffs", bool, false, gettext_noop("print diffs along with logs"))
238#ifdef option_bodies
239{
240 diffs = true;
241}
242#endif
243
244OPTVAR(drop_attr, std::set<std::string>, attrs_to_drop, )
245OPTION(drop_attr, drop_attr, true, "drop-attr",
246 gettext_noop("when rosterifying, drop attrs entries with the given key"))
247#ifdef option_bodies
248{
249 attrs_to_drop.insert(arg);
250}
251#endif
252
253OPT(dryrun, "dry-run", bool, false,
254 gettext_noop("don't perform the operation, just show what would have happened"))
255#ifdef option_bodies
256{
257 dryrun = true;
258}
259#endif
260
261OPTION(globals, dump, true, "dump",
262 gettext_noop("file to dump debugging log to, on failure"))
263#ifdef option_bodies
264{
265 global_sanity.set_dump_path(system_path(arg).as_external());
266}
267#endif
268
269OPTVAR(exclude, args_vector, exclude_patterns, )
270OPTION(exclude, exclude, true, "exclude",
271 gettext_noop("leave out anything described by its argument"))
272#ifdef option_bodies
273{
274 exclude_patterns.push_back(arg_type(arg));
275}
276#endif
277
278OPT(bookkeep_only, "bookkeep-only", bool, false,
279 gettext_noop("only update monotone's internal bookkeeping, not the filesystem"))
280#ifdef option_bodies
281{
282 bookkeep_only = true;
283}
284#endif
285
286GOPT(ssh_sign, "ssh-sign", std::string, "yes",
287 gettext_noop("controls use of ssh-agent. valid arguments are: "
288 "'yes' to use ssh-agent to make signatures if possible, "
289 "'no' to force use of monotone's internal code, "
290 "'only' to force use of ssh-agent, "
291 "'check' to sign with both and compare"))
292#ifdef option_bodies
293{
294 if (arg.empty())
295 throw bad_arg_internal(F("--ssh-sign requires a value "
296 "['yes', 'no', 'only', or 'check']").str());
297 if (arg != "yes"
298 && arg != "no"
299 && arg != "check"
300 && arg != "only") // XXX what does "only" do? not documented
301 throw bad_arg_internal(F("--ssh-sign must be set to 'yes', 'no', "
302 "'only', or 'check'").str());
303
304 ssh_sign = arg;
305}
306#endif
307
308OPT(full, "full", bool, false,
309 gettext_noop("print detailed version number"))
310#ifdef option_bodies
311{
312 full = true;
313}
314#endif
315
316GOPT(help, "help,h", bool, false, gettext_noop("display help message"))
317#ifdef option_bodies
318{
319 help = true;
320}
321#endif
322
323OPTVAR(include, args_vector, include_patterns, )
324OPTION(include, include, true, "include",
325 gettext_noop("include anything described by its argument"))
326#ifdef option_bodies
327{
328 include_patterns.push_back(arg_type(arg));
329}
330#endif
331
332GOPT(ignore_suspend_certs, "ignore-suspend-certs", bool, false,
333 gettext_noop("do not ignore revisions marked as suspended"))
334#ifdef option_bodies
335{
336 ignore_suspend_certs = true;
337}
338#endif
339
340
341OPTVAR(key, rsa_keypair_id, signing_key, )
342OPTION(globals, key, true, "key,k", gettext_noop("set key for signatures"))
343#ifdef option_bodies
344{
345 internalize_rsa_keypair_id(utf8(arg), signing_key);
346}
347#endif
348
349GOPT(key_dir, "keydir", system_path, get_default_keydir(),
350 gettext_noop("set location of key store"))
351#ifdef option_bodies
352{
353 key_dir = system_path(arg);
354}
355#endif
356
357OPTVAR(key_to_push, std::vector<rsa_keypair_id>, keys_to_push, )
358OPTION(key_to_push, key_to_push, true, "key-to-push",
359 gettext_noop("push the specified key even if it hasn't signed anything"))
360#ifdef option_bodies
361{
362 rsa_keypair_id keyid;
363 internalize_rsa_keypair_id(utf8(arg), keyid);
364 keys_to_push.push_back(keyid);
365}
366#endif
367
368OPT(last, "last", long, -1,
369 gettext_noop("limit log output to the last number of entries"))
370#ifdef option_bodies
371{
372 last = boost::lexical_cast<long>(arg);
373 if (last <= 0)
374 throw bad_arg_internal(F("cannot be zero or negative").str());
375}
376#endif
377
378OPTION(globals, log, true, "log", gettext_noop("file to write the log to"))
379#ifdef option_bodies
380{
381 ui.redirect_log_to(system_path(arg));
382}
383#endif
384
385OPTSET(messages)
386OPTVAR(messages, std::vector<std::string>, message, )
387OPTVAR(messages, utf8, msgfile, )
388OPTION(messages, message, true, "message,m",
389 gettext_noop("set commit changelog message"))
390#ifdef option_bodies
391{
392 message.push_back(arg);
393}
394#endif
395OPTION(messages, msgfile, true, "message-file",
396 gettext_noop("set filename containing commit changelog message"))
397#ifdef option_bodies
398{
399 msgfile = utf8(arg);
400}
401#endif
402
403OPT(missing, "missing", bool, false,
404 gettext_noop("perform the operations for files missing from workspace"))
405#ifdef option_bodies
406{
407 missing = true;
408}
409#endif
410
411OPT(next, "next", long, -1,
412 gettext_noop("limit log output to the next number of entries"))
413#ifdef option_bodies
414{
415 next = boost::lexical_cast<long>(arg);
416 if (next <= 0)
417 throw bad_arg_internal(F("cannot be zero or negative").str());
418}
419#endif
420
421OPT(no_files, "no-files", bool, false,
422 gettext_noop("exclude files when printing logs"))
423#ifdef option_bodies
424{
425 no_files = true;
426}
427#endif
428
429OPT(no_graph, "no-graph", bool, false,
430 gettext_noop("do not use ASCII graph to display ancestry"))
431#ifdef option_bodies
432{
433 no_graph = true;
434}
435#endif
436
437OPT(no_ignore, "no-respect-ignore", bool, false,
438 gettext_noop("do not ignore any files"))
439#ifdef option_bodies
440{
441 no_ignore = true;
442}
443#endif
444
445OPT(no_merges, "no-merges", bool, false,
446 gettext_noop("exclude merges when printing logs"))
447#ifdef option_bodies
448{
449 no_merges = true;
450}
451#endif
452
453GOPT(norc, "norc", bool, false,
454gettext_noop("do not load ~/.monotone/monotonerc or _MTN/monotonerc lua files"))
455#ifdef option_bodies
456{
457 norc = true;
458}
459#endif
460
461GOPT(nostd, "nostd", bool, false,
462 gettext_noop("do not load standard lua hooks"))
463#ifdef option_bodies
464{
465 nostd = true;
466}
467#endif
468
469OPT(pidfile, "pid-file", system_path, ,
470 gettext_noop("record process id of server"))
471#ifdef option_bodies
472{
473 pidfile = system_path(arg);
474}
475#endif
476
477GOPT(quiet, "quiet", bool, false,
478 gettext_noop("suppress verbose, informational and progress messages"))
479#ifdef option_bodies
480{
481 quiet = true;
482 global_sanity.set_quiet();
483 ui.set_tick_write_nothing();
484}
485#endif
486
487GOPT(extra_rcfiles, "rcfile", args_vector, ,
488 gettext_noop("load extra rc file"))
489#ifdef option_bodies
490{
491 extra_rcfiles.push_back(arg_type(arg));
492}
493#endif
494
495GOPT(reallyquiet, "reallyquiet", bool, false,
496gettext_noop("suppress warning, verbose, informational and progress messages"))
497#ifdef option_bodies
498{
499 reallyquiet = true;
500 global_sanity.set_reallyquiet();
501 ui.set_tick_write_nothing();
502}
503#endif
504
505OPT(recursive, "recursive,R", bool, false,
506 gettext_noop("also operate on the contents of any listed directories"))
507#ifdef option_bodies
508{
509 recursive = true;
510}
511#endif
512
513OPTVAR(revision, args_vector, revision_selectors, )
514OPTION(revision, revision, true, "revision,r",
515 gettext_noop("select revision id for operation"))
516#ifdef option_bodies
517{
518 revision_selectors.push_back(arg_type(arg));
519}
520#endif
521
522GOPT(root, "root", std::string, ,
523 gettext_noop("limit search for workspace to specified root"))
524#ifdef option_bodies
525{
526 root = arg;
527}
528#endif
529
530OPT(set_default, "set-default", bool, false,
531 gettext_noop("use the current arguments as the future default"))
532#ifdef option_bodies
533{
534 set_default = true;
535}
536#endif
537
538GOPT(ticker, "ticker", std::string, ,
539 gettext_noop("set ticker style (count|dot|none)"))
540#ifdef option_bodies
541{
542 ticker = arg;
543 if (ticker == "none" || global_sanity.quiet_p())
544 ui.set_tick_write_nothing();
545 else if (ticker == "dot")
546 ui.set_tick_write_dot();
547 else if (ticker == "count")
548 ui.set_tick_write_count();
549 else
550 throw bad_arg_internal(F("argument must be 'none', 'dot', or 'count'").str());
551}
552#endif
553
554OPT(from, "from", args_vector, , gettext_noop("revision(s) to start logging at"))
555#ifdef option_bodies
556{
557 from.push_back(arg_type(arg));
558}
559#endif
560
561OPT(to, "to", args_vector, , gettext_noop("revision(s) to stop logging at"))
562#ifdef option_bodies
563{
564 to.push_back(arg_type(arg));
565}
566#endif
567
568OPT(unknown, "unknown", bool, false,
569 gettext_noop("perform the operations for unknown files from workspace"))
570#ifdef option_bodies
571{
572 unknown = true;
573}
574
575#endif
576
577OPT(verbose, "verbose", bool, false,
578 gettext_noop("verbose completion output"))
579#ifdef option_bodies
580{
581 verbose = true;
582}
583#endif
584
585GOPT(version, "version", bool, false,
586 gettext_noop("print version number, then exit"))
587#ifdef option_bodies
588{
589 version = true;
590}
591#endif
592
593OPTION(globals, xargs, true, "xargs,@",
594 gettext_noop("insert command line arguments taken from the given file"))
595#ifdef option_bodies
596{
597}
598#endif
599
600OPTSET(automate_inventory_opts)
601OPTVAR(automate_inventory_opts, bool, no_ignored, false)
602OPTVAR(automate_inventory_opts, bool, no_unknown, false)
603OPTVAR(automate_inventory_opts, bool, no_unchanged, false)
604OPTVAR(automate_inventory_opts, bool, no_corresponding_renames, false)
605
606OPTION(automate_inventory_opts, no_ignored, false, "no-ignored",
607 gettext_noop("don't output ignored files"))
608#ifdef option_bodies
609{
610 no_ignored = true;
611}
612#endif
613
614OPTION(automate_inventory_opts, no_unknown, false, "no-unknown",
615 gettext_noop("don't output unknown files"))
616#ifdef option_bodies
617{
618 no_unknown = true;
619}
620#endif
621
622OPTION(automate_inventory_opts, no_unchanged, false, "no-unchanged",
623 gettext_noop("don't output unchanged files"))
624#ifdef option_bodies
625{
626 no_unchanged = true;
627}
628#endif
629
630OPTION(automate_inventory_opts, no_corresponding_renames, false, "no-corresponding-renames",
631 gettext_noop("don't output corresponding renames if restricted on such nodes"))
632#ifdef option_bodies
633{
634 no_corresponding_renames = true;
635}
636#endif
637
638// Local Variables:
639// mode: C++
640// fill-column: 76
641// c-file-style: "gnu"
642// indent-tabs-mode: nil
643// End:
644// 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