summaryrefslogtreecommitdiff
path: root/doc/cli.1
blob: a50a1bcd7a4969fd087883e53d492a12298737f1 (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
.\" Process this file with
.\" groff -man -Tascii cli.1
.\"
.TH CLI 1 "December 2009" "CLI 1.2.0"
.SH NAME
cli \- command line interface compiler for C++
.\"
.\"
.\"
.\"--------------------------------------------------------------------
.SH SYNOPSIS
.\"--------------------------------------------------------------------
.B cli
.B [
.I options
.B ]
.I file
.\"
.\"
.\"
.\"--------------------------------------------------------------------
.SH DESCRIPTION
.\"--------------------------------------------------------------------
.B cli
generates C++ implementation and documentation in various formats for a
command line interface defined in the CLI language. For an input file in
the form
.B name.cli
the following is generated. By default or if the
.B --generate-cxx
option is specified, the following C++ files are generated:
.B name.hxx
(header file),
.B name.ixx
(inline file, generated unless the
.B --suppress-inline
option is specified), and
.B name.cxx (source file).
If the
.B --generate-html
option is specified, then the
.B name.html
HTML documentation file is generated. If the
.B --generate-man
option is specified, then the
.B name.1
man page file is generated. When
.B --generate-html
or
.B --generate-man
is specified, the
.B --stdout
option can be used to redirect the output to STDOUT instead of a file.
.\"
.\"
.\"
.\"--------------------------------------------------------------------
.SH OPTIONS
.\"--------------------------------------------------------------------
.IP "\fB--help\fR"
Print usage information and exit\.
.IP "\fB--version\fR"
Print version and exit\.
.IP "\fB--include-path\fR|\fB-I\fR \fIdir\fR"
Search \fIdir\fR for bracket-included (\fB<>\fR) options files\.
.IP "\fB--output-dir\fR|\fB-o\fR \fIdir\fR"
Write the generated files to \fIdir\fR instead of the current directory\.
.IP "\fB--generate-modifier\fR"
Generate option value modifiers in addition to accessors\.
.IP "\fB--generate-specifier\fR"
Generate functions for determining whether the option was specified on the
command line\.
.IP "\fB--generate-parse\fR"
Generate \fBparse()\fR 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\.
.IP "\fB--generate-description\fR"
Generate the option description list that can be examined at runtime\.
.IP "\fB--generate-file-scanner\fR"
Generate the argv_file_scanner\fR implementation\. This scanner is capable of
reading command line arguments from the argv\fR array as well as files
specified with command line options\.
.IP "\fB--suppress-inline\fR"
Generate all functions non-inline\. By default simple functions are made
inline\. This option suppresses creation of the inline file\.
.IP "\fB--cli-namespace\fR \fIns\fR"
Generate the CLI support types in the \fIns\fR namespace (\fBcli\fR by
default)\. The namespace can be nested, for example \fBdetails::cli\fR\. If
the namespace is empty, then the support types are generated in the global
namespace\.
.IP "\fB--ostream-type\fR \fItype\fR"
Output stream type instead of the default \fBstd::ostream\fR that should be
used to print usage and exception information\.
.IP "\fB--generate-cxx\fR"
Generate C++ code\. If neither \fB--generate-man\fR nor \fB--generate-html\fR
is specified, this mode is assumed by default\.
.IP "\fB--generate-man\fR"
Generate documentation in the man page format\.
.IP "\fB--generate-html\fR"
Generate documentation in the HTML format\.
.IP "\fB--stdout\fR"
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\.
.IP "\fB--suppress-undocumented\fR"
Suppress the generation of documentation entries for undocumented options\.
.IP "\fB--suppress-usage\fR"
Suppress the generation of the usage printing code\.
.IP "\fB--long-usage\fR"
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\.
.IP "\fB--short-usage\fR"
If specified together with \fB--long-usage\fR, generate both short and long
usage versions\. In this mode, the usage printing functions are called
\fBprint_short_usage()\fR and \fBprint_long_usage()\fR and for the long usage
the long documentation string is always used, even if the short version is
provided\.
.IP "\fB--page-usage\fR \fIname\fR"
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 \fIname\fR 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:

.nf
--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
.fi

If both \fB--long-usage\fR and \fB--short-usage\fR options are specified, then
two functions are generated with the \fB*short_usage()\fR and
\fB*long_usage()\fR suffixes\.
.IP "\fB--option-length\fR \fIlen\fR"
Indent option descriptions \fIlen\fR 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\.
.IP "\fB--ansi-color\fR"
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 \fBless\fR(1)\fR, it will display
them correctly\.
.IP "\fB--exclude-base\fR"
Exclude base class information from usage and documentation\.
.IP "\fB--class\fR \fIfq-name\fR"
Generate the man page or HTML documentation only for the \fIfq-name\fR options
class\. The \fIfq-name\fR name should be a fully-qualified options class name,
for example, \fBapp::options\fR\. 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\.
.IP "\fB--docvar\fR|\fB-v\fR \fIname\fR=\fIval\fR"
Set documentation variable \fIname\fR to the value \fIval\fR\. Documentation
variables can be substituted in prologues and epilogues (see
\fB--*-prologue*\fR and \fB--*-epilogue*\fR options) using the
\fB$\fR\fIname\fR\fB$\fR expansion syntax (use \fB$$\fR to escape expansion)\.
They can also be defined in \fB\.cli\fR files using the
"\e\fIname\fR=\fIval\fR"\fR syntax\.
.IP "\fB--hxx-prologue\fR \fItext\fR"
Insert \fItext\fR at the beginning of the generated C++ header file\.
.IP "\fB--ixx-prologue\fR \fItext\fR"
Insert \fItext\fR at the beginning of the generated C++ inline file\.
.IP "\fB--cxx-prologue\fR \fItext\fR"
Insert \fItext\fR at the beginning of the generated C++ source file\.
.IP "\fB--man-prologue\fR \fItext\fR"
Insert \fItext\fR at the beginning of the generated man page file\.
.IP "\fB--html-prologue\fR \fItext\fR"
Insert \fItext\fR at the beginning of the generated HTML file\.
.IP "\fB--hxx-epilogue\fR \fItext\fR"
Insert \fItext\fR at the end of the generated C++ header file\.
.IP "\fB--ixx-epilogue\fR \fItext\fR"
Insert \fItext\fR at the end of the generated C++ inline file\.
.IP "\fB--cxx-epilogue\fR \fItext\fR"
Insert \fItext\fR at the end of the generated C++ source file\.
.IP "\fB--man-epilogue\fR \fItext\fR"
Insert \fItext\fR at the end of the generated man page text\.
.IP "\fB--html-epilogue\fR \fItext\fR"
Insert \fItext\fR at the end of the generated HTML text\.
.IP "\fB--hxx-prologue-file\fR \fIfile\fR"
Insert the content of \fIfile\fR at the beginning of the generated C++ header
file\.
.IP "\fB--ixx-prologue-file\fR \fIfile\fR"
Insert the content of \fIfile\fR at the beginning of the generated C++ inline
file\.
.IP "\fB--cxx-prologue-file\fR \fIfile\fR"
Insert the content of \fIfile\fR at the beginning of the generated C++ source
file\.
.IP "\fB--man-prologue-file\fR \fIfile\fR"
Insert the content of \fIfile\fR at the beginning of the generated man page
file\.
.IP "\fB--html-prologue-file\fR \fIfile\fR"
Insert the content of \fIfile\fR at the beginning of the generated HTML file\.
.IP "\fB--hxx-epilogue-file\fR \fIfile\fR"
Insert the content of \fIfile\fR at the end of the generated C++ header file\.
.IP "\fB--ixx-epilogue-file\fR \fIfile\fR"
Insert the content of \fIfile\fR at the end of the generated C++ inline file\.
.IP "\fB--cxx-epilogue-file\fR \fIfile\fR"
Insert the content of \fIfile\fR at the end of the generated C++ source file\.
.IP "\fB--man-epilogue-file\fR \fIfile\fR"
Insert the content of \fIfile\fR at the end of the generated man page file\.
.IP "\fB--html-epilogue-file\fR \fIfile\fR"
Insert the content of \fIfile\fR at the end of the generated HTML file\.
.IP "\fB--hxx-suffix\fR \fIsuffix\fR"
Use \fIsuffix\fR instead of the default \fB\.hxx\fR to construct the name of
the generated header file\.
.IP "\fB--ixx-suffix\fR \fIsuffix\fR"
Use \fIsuffix\fR instead of the default \fB\.ixx\fR to construct the name of
the generated inline file\.
.IP "\fB--cxx-suffix\fR \fIsuffix\fR"
Use \fIsuffix\fR instead of the default \fB\.cxx\fR to construct the name of
the generated source file\.
.IP "\fB--man-suffix\fR \fIsuffix\fR"
Use \fIsuffix\fR instead of the default \fB\.1\fR to construct the name of the
generated man page file\.
.IP "\fB--html-suffix\fR \fIsuffix\fR"
Use \fIsuffix\fR instead of the default \fB\.html\fR to construct the name of
the generated HTML file\.
.IP "\fB--option-prefix\fR \fIprefix\fR"
Use \fIprefix\fR instead of the default \fB-\fR 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\.
.IP "\fB--option-separator\fR \fIsep\fR"
Use \fIsep\fR instead of the default \fB--\fR 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\.
.IP "\fB--include-with-brackets\fR"
Use angle brackets (<>) instead of quotes ("") in the generated \fB#include\fR
directives\.
.IP "\fB--include-prefix\fR \fIprefix\fR"
Add \fIprefix\fR to the generated \fB#include\fR directive paths\.
.IP "\fB--guard-prefix\fR \fIprefix\fR"
Add \fIprefix\fR 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\.
.IP "\fB--reserved-name\fR \fIname\fR=\fIrep\fR"
Add \fIname\fR with an optional \fIrep\fR 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\.
.IP "\fB--options-file\fR \fIfile\fR"
Read additional options from \fIfile\fR with each option appearing on a
separate line optionally followed by space and an option value\. Empty lines
and lines starting with \fB#\fR are ignored\. Option values can be enclosed in
double (\fB"\fR) or single (\fB'\fR) 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 \fB'"x"'\fR\. 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 \fB--options-file\fR option is specified except that the shell escaping
and quoting is not required\. Repeat this option to specify more than one
options file\.
.\"
.\" DIAGNOSTICS
.\"
.SH DIAGNOSTICS
If the input file is not a valid CLI definition,
.B cli
will issue diagnostic messages to STDERR and exit with non-zero exit code.
.\"
.\" BUGS
.\"
.SH BUGS
Send bug reports to the cli-users@codesynthesis.com mailing list.
.\"
.\" COPYRIGHT
.\"
.SH COPYRIGHT
Copyright (c) 2009-2011 Code Synthesis Tools CC.

Permission is granted to copy, distribute and/or modify this document under
the terms of the MIT License. Copy of this license can be obtained from
http://www.codesynthesis.com/licenses/mit.txt