summaryrefslogtreecommitdiff
path: root/cli/options.cli
blob: 8a4a3e02dd366110e210e17300daebaed88aafae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
// file      : cli/options.cli
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license   : MIT; see accompanying LICENSE file

// NOTE: Make sure you have a working CLI compiler around before
// modifying this file.
//

include <map>;
include <string>;
include <vector>;
include <cstddef>;

include "option-types.hxx";

class options
{
  bool --help {"Print usage information and exit."};
  bool --version {"Print version and exit."};

  std::vector<std::string> --include-path | -I
  {
    "<dir>",
    "Search <dir> for bracket-included (\cb{<>}) options files."
  };

  std::string --output-dir | -o
  {
    "<dir>",
    "Write the generated files to <dir> instead of the current directory."
  };

  cxx_version --std = cxx_version::cxx98
  {
    "<version>",
    "Specify the C++ standard that should be used during compilation.
     Valid values are \cb{c++98} (default), \cb{c++11}, and \cb{c++14}."
  };

  bool --generate-modifier
  {
    "Generate option value modifiers in addition to accessors."
  };

  bool --generate-specifier
  {
    "Generate functions for determining whether the option was specified
     on the command line."
  };

  bool --generate-parse
  {
    "Generate \cb{parse()} functions instead of parsing constructors. This
     is primarily useful for being able to parse into an already initialized
     options class instance, for example, to implement merging/overriding."
  };

  bool --generate-description
  {
    "Generate the option description list that can be examined at runtime."
  };

  bool --generate-file-scanner
  {
    "Generate the \c{argv_file_scanner} implementation. This scanner is
     capable of reading command line arguments from the \c{argv} array as
     well as files specified with command line options."
  };

  bool --suppress-inline
  {
    "Generate all functions non-inline. By default simple functions are
     made inline. This option suppresses creation of the inline file."
  };

  std::string --cli-namespace = "::cli"
  {
    "<ns>",
    "Generate the CLI support types in the <ns> namespace (\cb{cli} by
     default). The namespace can be nested, for example \cb{details::cli}.
     If the namespace is empty, then the support types are generated in
     the global namespace."
  };

  std::string --ostream-type = "::std::ostream"
  {
    "<type>",
    "Output stream type instead of the default \cb{std::ostream} that
     should be used to print usage and exception information."
  };

  bool --generate-cxx
  {
    "Generate C++ code. If neither \cb{--generate-man}, \cb{--generate-html},
     nor \cb{--generate-txt} is specified, this mode is assumed by default."
  };

  bool --generate-man
  {
    "Generate documentation in the man page format."
  };

  bool --generate-html
  {
    "Generate documentation in the HTML format."
  };

  bool --generate-txt
  {
    "Generate documentation in the plain text format, similar to usage."
  };

  bool --stdout
  {
    "Write output to STDOUT instead of a file. This option is not valid
     when generating C++ code and is normally used to combine generated
     documentation for several option classes in a single file."
  };

  bool --suppress-undocumented
  {
    "Suppress the generation of documentation entries for undocumented
     options."
  };

  bool --suppress-usage
  {
    "Suppress the generation of the usage printing code."
  };

  bool --long-usage
  {
    "If no short documentation string is provided, use the complete
     long documentation string in usage. By default, in this situation
     only the first sentence from the long string is used."
  };

  bool --short-usage
  {
    "If specified together with \cb{--long-usage}, generate both short
     and long usage versions. In this mode, the long usage printing function
     is called \cb{print_long_usage()} and in its implementation the long
     documentation string is always used, even if the short version is
     provided."
  };

  std::string --page-usage
  {
    "<name>",
    "Generate the combined usage printing code for the entire page.
     Specifically, this will include all the namespace-level documentation as
     well as usage for all the options classes printed in the order they are
     defined in the main translation unit (documentation/classes from included
     units are ignored except for base classes).

     The <name> argument is used as a prefix to form the name of the usage
     printing function. It can include the namespace qualification as well
     as documentation variable expansion, for example:

     \
     --page-usage print_         # print_usage() in global namespace
     --page-usage app::print_    # print_usage() in app namespace
     --page-usage print_$name$_  # print_foo_usage() if name is foo
     \

     If both \cb{--long-usage} and \cb{--short-usage} options are specified,
     then the long usage function has the \cb{*long_usage()} suffix."
  };

  std::size_t --option-length = 0
  {
    "<len>",
    "Indent option descriptions <len> characters when printing usage. This is
     useful when you have multiple options classes, potentially in separate
     files, and would like their usage to have the same indentation level."
  };

  bool --ansi-color
  {
    "Use ANSI color escape sequences when printing usage. By \"color\" we
     really only mean the bold and underline modifiers. Note that Windows
     console does not recognize ANSI escape sequences and will display
     them as garbage. However, if you pipe such output through \cb{less(1)},
     it will display them correctly."
  };

  bool --exclude-base
  {
    "Exclude base class information from usage and documentation."
  };

  bool --include-base-last
  {
    "Include base class information after derived for usage and documentation.
     By default, base classes are included first."
  };

  std::map<std::string, std::string> --class-doc
  {
    "<name>=<kind>",
    "Specify the documentation <kind> that should be used for the options
     class <name>. The <name> value should be a fully-qualified class name,
     for example, \cb{app::options}. The <kind> value can be \cb{short},
     \cb{long}, or \cb{exclude}. If the value is \cb{exclude}, then the
     class documentation is excluded from usage and man/HTML/text output. For
     usage, the \cb{short} and \cb{long} values determine which usage
     function will be called when the class is used as base or as part of
     the page usage (see \cb{--page-usage}). For man/HTML/text, these values
     determine which documentation strings are used in the output."
  };

  std::vector<std::string> --class
  {
    "<name>",
    "Generate the man page, HTML, or text documentation only for the options
     class <name>. The <name> value should be a fully-qualified options class
     name, for example, \cb{app::options}. To generate documentation for
     multiple classes, repeat this option and the documentation will be
     produced in the order specified. This functionality is useful if you need
     to assemble documentation from multiple classes in a specific order or to
     insert custom documentation between options belonging to different
     classes."
  };

  std::map<std::string, std::string> --docvar|-v
  {
    "<name>=<val>",
    "Set documentation variable <name> to the value <val>. Documentation
     variables can be substituted in prologues and epilogues (see
     \cb{--*-prologue*} and \cb{--*-epilogue*} options) using the
     \cb{$}<name>\cb{$} expansion syntax (use \cb{$$} to escape expansion).
     They can also be defined in \cb{.cli} files using the
     \c{\"\\<name>=<val>\"} syntax."
  };

  std::vector<std::string> --link-regex
  {
    "<regex>",
    "Add <regex> to the list of regular expressions used to transform link
     targets in the generated documentation. The argument to this option
     is a Perl-like regular expression in the form
     \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. Any character can be
     used as a delimiter instead of '\cb{/}' and the delimiter can be escaped
     inside \ci{pattern} and \ci{replacement} with a backslash (\cb{\\}).
     You can specify multiple regular expressions by repeating this option.
     All the regular expressions are tried in the order specified and the
     first expression that matches is used. Use the \cb{--link-regex-trace}
     option to debug link transformation."
  };

  bool --link-regex-trace
  {
    "Trace the process of applying regular expressions specified with the
     \cb{--link-regex} option. Use this option to find out why your regular
     expressions don't do what you expected them to do."
  };

  // Prologues.
  //
  std::vector<std::string> --hxx-prologue
  {
    "<text>",
    "Insert <text> at the beginning of the generated C++ header file."
  };

  std::vector<std::string> --ixx-prologue
  {
    "<text>",
    "Insert <text> at the beginning of the generated C++ inline file."
  };

  std::vector<std::string> --cxx-prologue
  {
    "<text>",
    "Insert <text> at the beginning of the generated C++ source file."
  };

  std::vector<std::string> --man-prologue
  {
    "<text>",
    "Insert <text> at the beginning of the generated man page file."
  };

  std::vector<std::string> --html-prologue
  {
    "<text>",
    "Insert <text> at the beginning of the generated HTML file."
  };

  std::vector<std::string> --txt-prologue
  {
    "<text>",
    "Insert <text> at the beginning of the generated text file."
  };

  // Epilogues.
  //
  std::vector<std::string> --hxx-epilogue
  {
    "<text>",
    "Insert <text> at the end of the generated C++ header file."
  };

  std::vector<std::string> --ixx-epilogue
  {
    "<text>",
    "Insert <text> at the end of the generated C++ inline file."
  };

  std::vector<std::string> --cxx-epilogue
  {
    "<text>",
    "Insert <text> at the end of the generated C++ source file."
  };

  std::vector<std::string> --man-epilogue
  {
    "<text>",
    "Insert <text> at the end of the generated man page file."
  };

  std::vector<std::string> --html-epilogue
  {
    "<text>",
    "Insert <text> at the end of the generated HTML file."
  };

  std::vector<std::string> --txt-epilogue
  {
    "<text>",
    "Insert <text> at the end of the generated text file."
  };

  // Prologue files.
  //
  std::string --hxx-prologue-file
  {
    "<file>",
    "Insert the content of <file> at the beginning of the generated C++
     header file."
  };

  std::string --ixx-prologue-file
  {
    "<file>",
    "Insert the content of <file> at the beginning of the generated C++
     inline file."
  };

  std::string --cxx-prologue-file
  {
    "<file>",
    "Insert the content of <file> at the beginning of the generated C++
     source file."
  };

  std::string --man-prologue-file
  {
    "<file>",
    "Insert the content of <file> at the beginning of the generated man
     page file."
  };

  std::string --html-prologue-file
  {
    "<file>",
    "Insert the content of <file> at the beginning of the generated HTML
     file."
  };

  std::string --txt-prologue-file
  {
    "<file>",
    "Insert the content of <file> at the beginning of the generated text
     file."
  };

  // Epilogue files.
  //
  std::string --hxx-epilogue-file
  {
    "<file>",
    "Insert the content of <file> at the end of the generated C++ header
     file."
  };

  std::string --ixx-epilogue-file
  {
    "<file>",
    "Insert the content of <file> at the end of the generated C++ inline
     file."
  };

  std::string --cxx-epilogue-file
  {
    "<file>",
    "Insert the content of <file> at the end of the generated C++ source
     file."
  };

  std::string --man-epilogue-file
  {
    "<file>",
    "Insert the content of <file> at the end of the generated man page file."
  };

  std::string --html-epilogue-file
  {
    "<file>",
    "Insert the content of <file> at the end of the generated HTML file."
  };

  std::string --txt-epilogue-file
  {
    "<file>",
    "Insert the content of <file> at the end of the generated text file."
  };

  // Output.
  //
  std::string --output-prefix
  {
    "<prefix>",
    "Add <prefix> at the beginning of the generated output file name(s)."
  };

  std::string --output-suffix
  {
    "<suffix>",
    "Add <suffix> at the end of the generated output file name(s). Note that
     it is added before any file type-specific suffixes; see \cb{--*-suffix}
     below."
  };

  std::string --hxx-suffix = ".hxx"
  {
    "<suffix>",
    "Use <suffix> instead of the default \cb{.hxx} to construct the name of
     the generated header file."
  };

  std::string --ixx-suffix = ".ixx"
  {
    "<suffix>",
    "Use <suffix> instead of the default \cb{.ixx} to construct the name of
     the generated inline file."
  };

  std::string --cxx-suffix = ".cxx"
  {
    "<suffix>",
    "Use <suffix> instead of the default \cb{.cxx} to construct the name of
     the generated source file."
  };

  std::string --man-suffix = ".1"
  {
    "<suffix>",
    "Use <suffix> instead of the default \cb{.1} to construct the name of
     the generated man page file."
  };

  std::string --html-suffix = ".html"
  {
    "<suffix>",
    "Use <suffix> instead of the default \cb{.html} to construct the name
     of the generated HTML file."
  };

  std::string --txt-suffix = ".txt"
  {
    "<suffix>",
    "Use <suffix> instead of the default \cb{.txt} to construct the name of
     the generated text file."
  };

  std::string --option-prefix = "-"
  {
    "<prefix>",
    "Use <prefix> instead of the default '\cb{-}' as an option prefix. Unknown
     command line arguments that start with this prefix are treated as unknown
     options. If you set the option prefix to the empty value, then all the
     unknown command line arguments will be treated as program arguments."
  };

  std::string --option-separator = "--"
  {
    "<sep>",
    "Use <sep> instead of the default '\cb{--}' as an optional separator
     between options and arguments. All the command line arguments that are
     parsed after this separator are treated as program arguments. Set the
     option separator to the empty value if you don't want this functionality."
  };

  bool --include-with-brackets
  {
    "Use angle brackets (\cb{<>}) instead of quotes (\cb{\"\"}) in the
     generated \cb{#include} directives."
  };

  std::string --include-prefix
  {
    "<prefix>",
    "Add <prefix> to the generated \cb{#include} directive paths."
  };

  std::string --guard-prefix
  {
    "<prefix>",
    "Add <prefix> to the generated header inclusion guards. The prefix is
     transformed to upper case and characters that are illegal in a
     preprocessor macro name are replaced with underscores."
  };

  std::map<std::string, std::string> --reserved-name
  {
    "<name>=<rep>",
    "Add <name> with an optional <rep> replacement to the list of names
     that should not be used as identifiers. If provided, the replacement
     name is used instead. All C++ keywords are already in this list."
  };

  // This is a "fake" option in that it is actually handled by
  // argv_file_scanner. We have it here to get the documentation.
  //
  std::string --options-file
  {
    "<file>",
    "Read additional options from <file> with each option appearing on a
     separate line optionally followed by space and an option value. Empty
     lines and lines starting with \cb{#} are ignored. Option values can
     be enclosed in double (\cb{\"}) or single (\cb{'}) quotes  to preserve
     leading and trailing whitespaces as well as to specify empty values.
     If the value itself contains trailing or leading quotes, enclose it
     with an extra pair of quotes, for example \cb{'\"x\"'}. Non-leading
     and non-trailing quotes are interpreted as being part of the option
     value.

     The semantics of providing options in a file is equivalent to providing
     the same set of options in the same order on the command line at the
     point where the \cb{--options-file} option is specified except that
     the shell escaping and quoting is not required. Repeat this option
     to specify more than one options file."
  };
};