blob: b3e9840b1fc2b2b877ba8cc5f7b6cd947c54b878 [file] [log] [blame]
Chris Lattner209c7f42001-07-23 23:03:12 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Chris Lattnerae853632002-07-25 19:27:01 +00002<html><head><title>CommandLine 2.0 Library Manual</title></head>
Chris Lattner209c7f42001-07-23 23:03:12 +00003<body bgcolor=white>
4
5<table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
Chris Lattnere76d4ab2002-08-06 19:36:06 +00006<tr><td>&nbsp; <font size=+3 color="#EEEEFF" face="Georgia,Palatino,Times,Roman"><b>CommandLine 2.0 Library Manual</b></font></td>
Chris Lattner209c7f42001-07-23 23:03:12 +00007</tr></table>
8
9<ol>
10 <li><a href="#introduction">Introduction</a>
11 <li><a href="#quickstart">Quick Start Guide</a>
12 <ol>
Chris Lattnerae853632002-07-25 19:27:01 +000013 <li><a href="#bool">Boolean Arguments</a>
14 <li><a href="#alias">Argument Aliases</a>
Chris Lattnere76d4ab2002-08-06 19:36:06 +000015 <li><a href="#onealternative">Selecting an alternative from a
16 set of possibilities</a>
Chris Lattner209c7f42001-07-23 23:03:12 +000017 <li><a href="#namedalternatives">Named alternatives</a>
Chris Lattnerae853632002-07-25 19:27:01 +000018 <li><a href="#list">Parsing a list of options</a>
Chris Lattner209c7f42001-07-23 23:03:12 +000019 </ol>
20 <li><a href="#referenceguide">Reference Guide</a>
Chris Lattnerae853632002-07-25 19:27:01 +000021 <ol>
Chris Lattnere76d4ab2002-08-06 19:36:06 +000022 <li><a href="#positional">Positional Arguments</a>
Chris Lattnerae853632002-07-25 19:27:01 +000023 <ul>
Chris Lattnere76d4ab2002-08-06 19:36:06 +000024 <li><a href="#--">Specifying positional options with hyphens</a>
25 <li><a href="#cl::ConsumeAfter">The <tt>cl::ConsumeAfter</tt>
26 modifier</a>
Chris Lattnerae853632002-07-25 19:27:01 +000027 </ul>
Chris Lattnere76d4ab2002-08-06 19:36:06 +000028 <li><a href="#storage">Internal vs External Storage</a>
29 <li><a href="#attributes">Option Attributes</a>
30 <li><a href="#modifiers">Option Modifiers</a>
Chris Lattnerae853632002-07-25 19:27:01 +000031 <ul>
Chris Lattnere76d4ab2002-08-06 19:36:06 +000032 <li><a href="#hiding">Hiding an option from <tt>--help</tt> output</a>
33 <li><a href="#numoccurances">Controlling the number of occurances
34 required and allowed</a>
35 <li><a href="#valrequired">Controlling whether or not a value must be
36 specified</a>
37 <li><a href="#formatting">Controlling other formatting options</a>
38 </ul>
39 <li><a href="#optionclasses">Option Classes</a>
40 <ul>
41 <li><a href="#cl::opt">The <tt>cl::opt</tt> class</a>
42 <li><a href="#cl::list">The <tt>cl::list</tt> class</a>
43 <li><a href="#cl::alias">The <tt>cl::alias</tt> class</a>
44 </ul>
45 <li><a href="#builtinparsers">Builtin parsers</a>
46 <ul>
47 <li><a href="#genericparser">The Generic <tt>parser&lt;t&gt;</tt>
48 parser</a>
49 <li><a href="#boolparser">The <tt>parser&lt;bool&gt;</tt>
50 specialization</a>
51 <li><a href="#stringparser">The <tt>parser&lt;string&gt;</tt>
52 specialization</a>
53 <li><a href="#intparser">The <tt>parser&lt;int&gt;</tt>
54 specialization</a>
55 <li><a href="#doubleparser">The <tt>parser&lt;double&gt;</tt> and
56 <tt>parser&lt;float&gt;</tt> specializations</a>
Chris Lattnerae853632002-07-25 19:27:01 +000057 </ul>
58 </ol>
Chris Lattner209c7f42001-07-23 23:03:12 +000059 <li><a href="#extensionguide">Extension Guide</a>
Chris Lattnerae853632002-07-25 19:27:01 +000060 <ol>
Chris Lattnere76d4ab2002-08-06 19:36:06 +000061 <li><a href="#customparser">Writing a custom parser</a>
62 <li><a href="#explotingexternal">Exploiting external storage</a>
63 <li><a href="#dynamicopts">Dynamically adding command line options</a>
Chris Lattnerae853632002-07-25 19:27:01 +000064 </ol>
Chris Lattnere76d4ab2002-08-06 19:36:06 +000065
66 <p><b>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a></b><p>
Chris Lattner209c7f42001-07-23 23:03:12 +000067</ol><p>
68
69
70<!-- *********************************************************************** -->
71</ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
72<tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
73<a name="introduction">Introduction
74</b></font></td></tr></table><ul>
75<!-- *********************************************************************** -->
76
Chris Lattnerae853632002-07-25 19:27:01 +000077This document describes the CommandLine argument processing library. It will
Chris Lattnere76d4ab2002-08-06 19:36:06 +000078show you how to use it, and what it can do. The CommandLine library uses a
79declarative approach to specifying the command line options that your program
80takes. By default, these options declarations implicitly hold the value parsed
81for the option declared (of course this <a href="#storage">can be
82changed</a>).<p>
Chris Lattner209c7f42001-07-23 23:03:12 +000083
Chris Lattnerae853632002-07-25 19:27:01 +000084Although there are a <b>lot</b> of command line argument parsing libraries out
85there in many different languages, none of them fit well with what I needed. By
86looking at the features and problems of other libraries, I designed the
87CommandLine library to have the following features:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +000088
89<ol>
Chris Lattnerae853632002-07-25 19:27:01 +000090<li>Speed: The CommandLine library is very quick and uses little resources. The
91parsing time of the library is directly proportional to the number of arguments
92parsed, not the the number of options recognized. Additionally, command line
93argument values are captured transparently into user defined variables, which
94can be accessed like any other variable (and with the same performance).<p>
Chris Lattner209c7f42001-07-23 23:03:12 +000095
Chris Lattnerae853632002-07-25 19:27:01 +000096<li>Type Safe: As a user of CommandLine, you don't have to worry about
97remembering the type of arguments that you want (is it an int? a string? a
98bool? an enum?) and keep casting it around. Not only does this help prevent
99error prone constructs, it also leads to dramatically cleaner source code.<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000100
Chris Lattnerae853632002-07-25 19:27:01 +0000101<li>No subclasses required: To use CommandLine, you instantiate variables that
102correspond to the arguments that you would like to capture, you don't subclass a
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000103parser. This means that you don't have to write <b>any</b> boilerplate code.<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000104
Chris Lattnerae853632002-07-25 19:27:01 +0000105<li>Globally accessible: Libraries can specify command line arguments that are
106automatically enabled in any tool that links to the library. This is possible
107because the application doesn't have to keep a "list" of arguments to pass to
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000108the parser. This also makes supporting <a href="#dynamicopts">dynamically
109loaded options</a> trivial.<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000110
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000111<li>More Clean: CommandLine supports enum and other types directly, meaning that
112there is less error and more security built into the library. You don't have to
113worry about whether your integral command line argument accidentally got
114assigned a value that is not valid for your enum type.<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000115
Chris Lattnerae853632002-07-25 19:27:01 +0000116<li>Powerful: The CommandLine library supports many different types of
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000117arguments, from simple <a href="#boolparser">boolean flags</a> to <a
118href="#cl::opt">scalars arguments</a> (<a href="#stringparser">strings</a>, <a
119href="#intparser">integers</a>, <a href="#genericparser">enums</a>, <a
120href="#doubleparser">doubles</a>), to <a href="#cl::list">lists of
121arguments</a>. This is possible because CommandLine is...<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000122
Chris Lattnerae853632002-07-25 19:27:01 +0000123<li>Extensible: It is very simple to add a new argument type to CommandLine.
124Simply specify the parser that you want to use with the command line option when
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000125you declare it. <a href="#customparser">Custom parsers</a> are no problem.<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000126
Chris Lattnerae853632002-07-25 19:27:01 +0000127<li>Labor Saving: The CommandLine library cuts down on the amount of grunt work
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000128that you, the user, have to do. For example, it automatically provides a
129<tt>--help</tt> option that shows the available command line options for your
130tool. Additionally, it does most of the basic correctness checking for you.<p>
131
132<li>Capable: The CommandLine library can handle lots of different forms of
133options often found in real programs. For example, <a
134href="#positional">positional</a> arguments, <tt>ls</tt> style <a
135href="#cl::Grouping">grouping</a> options (to allow processing '<tt>ls
136-lad</tt>' naturally), <tt>ld</tt> style <a href="#cl::Prefix">prefix</a>
137options (to parse '<tt>-lmalloc -L/usr/lib</tt>'), and <a
138href="#cl::ConsumeAfter">interpreter style options</a>.<p>
139
Chris Lattner209c7f42001-07-23 23:03:12 +0000140</ol>
141
Chris Lattnerae853632002-07-25 19:27:01 +0000142This document will hopefully let you jump in and start using CommandLine in your
143utility quickly and painlessly. Additionally it should be a simple reference
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000144manual to figure out how stuff works. If it is failing in some area (or you
145want an extension to the library), nag the author, <a
146href="mailto:sabre@nondot.org">Chris Lattner</a>.<p>
147
Chris Lattner209c7f42001-07-23 23:03:12 +0000148
149
150<!-- *********************************************************************** -->
151</ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0><tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
152<a name="quickstart">Quick Start Guide
153</b></font></td></tr></table><ul>
154<!-- *********************************************************************** -->
155
Chris Lattnerae853632002-07-25 19:27:01 +0000156This section of the manual runs through a simple CommandLine'ification of a
157basic compiler tool. This is intended to show you how to jump into using the
158CommandLine library in your own program, and show you some of the cool things it
159can do.<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000160
Chris Lattnerae853632002-07-25 19:27:01 +0000161To start out, you need to include the CommandLine header file into your
162program:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000163
164<pre>
Chris Lattnerae853632002-07-25 19:27:01 +0000165 #include "Support/CommandLine.h"
Chris Lattner209c7f42001-07-23 23:03:12 +0000166</pre><p>
167
168Additionally, you need to add this as the first line of your main program:<p>
169
170<pre>
171int main(int argc, char **argv) {
172 cl::ParseCommandLineOptions(argc, argv);
173 ...
174}
175</pre><p>
176
Chris Lattnerae853632002-07-25 19:27:01 +0000177... which actually parses the arguments and fills in the variable
178declarations.<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000179
Chris Lattnerae853632002-07-25 19:27:01 +0000180Now that you are ready to support command line arguments, we need to tell the
181system which ones we want, and what type of argument they are. The CommandLine
182library uses a declarative syntax to model cammand line arguments with the
183variable declarations that capture the parsed values. This means that for every
184command line option that you would like to support, there should be a variable
185declaration to capture the result. For example, in a compiler, we would like to
186support the unix standard '<tt>-o &lt;filename&gt;</tt>' option to specify where
187to put the output. With the CommandLine library, this is represented like
188this:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000189
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000190<pre><a name="value_desc_example">
191<a href="#cl::opt">cl::opt</a>&lt;string&gt; OutputFilename("<i>o</i>", <a href="#cl::desc">cl::desc</a>("<i>Specify output filename</i>"), <a href="#cl::value_desc">cl::value_desc</a>("<i>filename</i>"));
Chris Lattner209c7f42001-07-23 23:03:12 +0000192</pre><p>
193
Chris Lattnerae853632002-07-25 19:27:01 +0000194This declares a variable "<tt>OutputFilename</tt>" that is used to capture the
195result of the "<tt>o</tt>" argument (first parameter). We specify that this is
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000196a simple scalar option by using the "<tt><a href="#cl::opt">cl::opt</a></tt>"
197template (as opposed to the <a href="#list">"<tt>cl::list</tt>
198template</a>), and tell the CommandLine library that the data type that we are
199parsing is a string.<p>
Chris Lattnerae853632002-07-25 19:27:01 +0000200
201The second and third parameters (which are optional) are used to specify what to
202output for the "<tt>--help</tt>" option. In this case, we get a line that looks
203like this:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000204
205<pre>
Chris Lattnerae853632002-07-25 19:27:01 +0000206USAGE: compiler [options]
Chris Lattner209c7f42001-07-23 23:03:12 +0000207
Chris Lattnerae853632002-07-25 19:27:01 +0000208OPTIONS:
209 -help - display available options (--help-hidden for more)
210 -o &lt;filename&gt; - Specify output filename
211</pre>
212
213Because we specified that the command line option should parse using the
214<tt>string</tt> data type, the variable declared is automatically usable as a
215real string in all contexts that a normal C++ string object may be used. For
216example:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000217
218<pre>
219 ...
220 ofstream Output(OutputFilename.c_str());
221 if (Out.good()) ...
222 ...
223</pre><p>
224
Chris Lattnerae853632002-07-25 19:27:01 +0000225There are many different options that you can use to customize the command line
226option handling library, but the above example shows the general interface to
227these options. The options can be specified in any order, and are specified
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000228with helper functions like <a href="#cl::desc"><tt>cl::desc(...)</tt></a>, so
229there are no positional dependencies to have to remember. The available options
230are discussed in detail in the <a href="#referenceguide">Reference Guide</a>.<p>
231
Chris Lattner209c7f42001-07-23 23:03:12 +0000232
Chris Lattnerae853632002-07-25 19:27:01 +0000233Continuing the example, we would like to have our compiler take an input
234filename as well as an output filename, but we do not want the input filename to
235be specified with a hyphen (ie, not <tt>-filename.c</tt>). To support this
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000236style of argument, the CommandLine library allows for <a
237href="#positional">positional</a> arguments to be specified for the program.
238These positional arguments are filled with command line parameters that are not
239in option form. We use this feature like this:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000240
241<pre>
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000242<a href="#cl::opt">cl::opt</a>&lt;string&gt; InputFilename(<a href="#cl::Positional">cl::Positional</a>, <a href="#cl::desc">cl::desc</a>("<i>&lt;input file&gt;</i>"), <a href="#cl::init">cl::init</a>("<i>-</i>"));
Chris Lattner209c7f42001-07-23 23:03:12 +0000243</pre>
244
Chris Lattnerae853632002-07-25 19:27:01 +0000245This declaration indicates that the first positional argument should be treated
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000246as the input filename. Here we use the <tt><a
247href="#cl::init">cl::init</a></tt> option to specify an initial value for the
248command line option, which is used if the option is not specified (if you do not
249specify a <tt><a href="#cl::init">cl::init</a></tt> modifier for an option, then
250the default constructor for the data type is used to initialize the value).
Chris Lattnerae853632002-07-25 19:27:01 +0000251Command line options default to being optional, so if we would like to require
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000252that the user always specify an input filename, we would add the <tt><a
253href="#cl::Required">cl::Required</a></tt> flag, and we could eliminate the
254<tt><a href="#cl::init">cl::init</a></tt> modifier, like this:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000255
256<pre>
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000257<a href="#cl::opt">cl::opt</a>&lt;string&gt; InputFilename(<a href="#cl::Positional">cl::Positional</a>, <a href="#cl::desc">cl::desc</a>("<i>&lt;input file&gt;</i>"), <b><a href="#cl::Required">cl::Required</a></b>);
Chris Lattner209c7f42001-07-23 23:03:12 +0000258</pre>
259
Chris Lattnerae853632002-07-25 19:27:01 +0000260Again, the CommandLine library does not require the options to be specified in
261any particular order, so the above declaration is equivalent to:<p>
262
263<pre>
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000264<a href="#cl::opt">cl::opt</a>&lt;string&gt; InputFilename(<a href="#cl::Positional">cl::Positional</a>, <a href="#cl::Required">cl::Required</a>, <a href="#cl::desc">cl::desc</a>("<i>&lt;input file&gt;</i>"));
Chris Lattnerae853632002-07-25 19:27:01 +0000265</pre>
266
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000267By simply adding the <tt><a href="#cl::Required">cl::Required</a></tt> flag, the
268CommandLine library will automatically issue an error if the argument is not
269specified, which shifts all of the command line option verification code out of
270your application into the library. This is just one example of how using flags
271can alter the default behaviour of the library, on a per-option basis. By
272adding one of the declarations above, the <tt>--help</tt> option synopsis is now
273extended to:<p>
Chris Lattnerae853632002-07-25 19:27:01 +0000274
275<pre>
276USAGE: compiler [options] &lt;input file&gt;
277
278OPTIONS:
279 -help - display available options (--help-hidden for more)
280 -o &lt;filename&gt; - Specify output filename
281</pre>
282
283... indicating that an input filename is expected.<p>
284
Chris Lattner209c7f42001-07-23 23:03:12 +0000285
286<!-- ======================================================================= -->
287</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0><tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
Chris Lattnerae853632002-07-25 19:27:01 +0000288<a name="bool">Boolean Arguments
Chris Lattner209c7f42001-07-23 23:03:12 +0000289</b></font></td></tr></table><ul>
290
Chris Lattnerae853632002-07-25 19:27:01 +0000291In addition to input and output filenames, we would like the compiler example to
292support three boolean flags: "<tt>-f</tt>" to force overwriting of the output
293file, "<tt>--quiet</tt>" to enable quiet mode, and "<tt>-q</tt>" for backwards
294compatibility with some of our users. We can support these by declaring options
295of boolean type like this:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000296
297<pre>
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000298<a href="#cl::opt">cl::opt</a>&lt;bool&gt; Force ("<i>f</i>", <a href="#cl::desc">cl::desc</a>("<i>Overwrite output files</i>"));
299<a href="#cl::opt">cl::opt</a>&lt;bool&gt; Quiet ("<i>quiet</i>", <a href="#cl::desc">cl::desc</a>("<i>Don't print informational messages</i>"));
300<a href="#cl::opt">cl::opt</a>&lt;bool&gt; Quiet2("<i>q</i>", <a href="#cl::desc">cl::desc</a>("<i>Don't print informational messages</i>"), <a href="#cl::Hidden">cl::Hidden</a>);
Chris Lattner209c7f42001-07-23 23:03:12 +0000301</pre><p>
302
Chris Lattnerae853632002-07-25 19:27:01 +0000303This does what you would expect: it declares three boolean variables
304("<tt>Force</tt>", "<tt>Quiet</tt>", and "<tt>Quiet2</tt>") to recognize these
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000305options. Note that the "<tt>-q</tt>" option is specified with the "<a
306href="#cl::Hidden"><tt>cl::Hidden</tt></a>" flag. This modifier prevents it
307from being shown by the standard "<tt>--help</tt>" output (note that it is still
308shown in the "<tt>--help-hidden</tt>" output).<p>
Chris Lattnerae853632002-07-25 19:27:01 +0000309
310The CommandLine library uses a different parser for different data types. For
311example, in the string case, the argument passed to the option is copied
312literally into the content of the string variable... we obviously cannot do that
313in the boolean case, however, so we must use a smarter parser. In the case of
314the boolean parser, it allows no options (in which case it assigns the value of
315true to the variable), or it allows the values "<tt>true</tt>" or
316"<tt>false</tt>" to be specified, allowing any of the following inputs:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000317
318<pre>
Chris Lattnerae853632002-07-25 19:27:01 +0000319 compiler -f # No value, 'Force' == true
320 compiler -f=true # Value specified, 'Force' == true
321 compiler -f=TRUE # Value specified, 'Force' == true
322 compiler -f=FALSE # Value specified, 'Force' == false
323</pre>
324
325... you get the idea. The bool parser just turns the string values into boolean
326values, and rejects things like '<tt>compiler -f=foo</tt>'. Similarly, the
327float, double, and int parsers work like you would expect, using the
328'<tt>strtol</tt>' and '<tt>strtod</tt>' C library calls to parse the string
329value into the specified data type.<p>
330
331With the declarations above, "<tt>compiler --help</tt>" emits this:<p>
332
333<pre>
334USAGE: compiler [options] &lt;input file&gt;
Chris Lattner209c7f42001-07-23 23:03:12 +0000335
336OPTIONS:
337 -f - Overwrite output files
338 -o - Override output filename
339 -quiet - Don't print informational messages
340 -help - display available options (--help-hidden for more)
341</pre><p>
342
Chris Lattnerae853632002-07-25 19:27:01 +0000343and "<tt>opt --help-hidden</tt>" prints this:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000344
345<pre>
Chris Lattnerae853632002-07-25 19:27:01 +0000346USAGE: opt [options] &lt;input file&gt;
Chris Lattner209c7f42001-07-23 23:03:12 +0000347
348OPTIONS:
349 -f - Overwrite output files
350 -o - Override output filename
351 -q - Don't print informational messages
352 -quiet - Don't print informational messages
353 -help - display available options (--help-hidden for more)
354</pre><p>
355
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000356This brief example has shown you how to use the '<tt><a
357href="#cl::opt">cl::opt</a></tt>' class to parse simple scalar command line
358arguments. In addition to simple scalar arguments, the CommandLine library also
359provides primitives to support CommandLine option <a href="#alias">aliases</a>,
360and <a href="#list">lists</a> of options.<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000361
362
363<!-- ======================================================================= -->
364</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0><tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
Chris Lattnerae853632002-07-25 19:27:01 +0000365<a name="alias">Argument Aliases
Chris Lattner209c7f42001-07-23 23:03:12 +0000366</b></font></td></tr></table><ul>
367
Chris Lattnerae853632002-07-25 19:27:01 +0000368So far, the example works well, except for the fact that we need to check the
369quiet condition like this now:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000370
371<pre>
372...
373 if (!Quiet &amp;&amp; !Quiet2) printInformationalMessage(...);
374...
375</pre><p>
376
Chris Lattnerae853632002-07-25 19:27:01 +0000377... which is a real pain! Instead of defining two values for the same
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000378condition, we can use the "<tt><a href="#cl::alias">cl::alias</a></tt>" class to make the "<tt>-q</tt>"
Chris Lattnerae853632002-07-25 19:27:01 +0000379option an <b>alias</b> for the "<tt>-quiet</tt>" option, instead of providing
380a value itself:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000381
382<pre>
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000383<a href="#cl::opt">cl::opt</a>&lt;bool&gt; Force ("<i>f</i>", <a href="#cl::desc">cl::desc</a>("<i>Overwrite output files</i>"));
384<a href="#cl::opt">cl::opt</a>&lt;bool&gt; Quiet ("<i>quiet</i>", <a href="#cl::desc">cl::desc</a>("<i>Don't print informational messages</i>"));
385<a href="#cl::alias">cl::alias</a> QuietA("<i>q</i>", <a href="#cl::desc">cl::desc</a>("<i>Alias for -quiet</i>"), <a href="#cl::aliasopt">cl::aliasopt</a>(Quiet));
Chris Lattner209c7f42001-07-23 23:03:12 +0000386</pre><p>
387
Chris Lattnerae853632002-07-25 19:27:01 +0000388The third line (which is the only one we modified from above) defines a
389"<tt>-q</tt> alias that updates the "<tt>Quiet</tt>" variable (as specified by
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000390the <tt><a href="#cl::aliasopt">cl::aliasopt</a></tt> modifier) whenever it is
391specified. Because aliases do not hold state, the only thing the program has to
392query is the <tt>Quiet</tt> variable now. Another nice feature of aliases is
393that they automatically hide themselves from the <tt>-help</tt> output
394(although, again, they are still visible in the <tt>--help-hidden
395output</tt>).<p>
Chris Lattnerae853632002-07-25 19:27:01 +0000396
397Now the application code can simply use:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000398
399<pre>
400...
401 if (!Quiet) printInformationalMessage(...);
402...
403</pre><p>
404
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000405... which is much nicer! The "<tt><a href="#cl::alias">cl::alias</a></tt>" can be used to specify an
Chris Lattnerae853632002-07-25 19:27:01 +0000406alternative name for any variable type, and has many uses.<p>
407
Chris Lattner209c7f42001-07-23 23:03:12 +0000408
409
410<!-- ======================================================================= -->
411</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0><tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
Chris Lattnerae853632002-07-25 19:27:01 +0000412<a name="onealternative">Selecting an alternative from a set of possibilities
Chris Lattner209c7f42001-07-23 23:03:12 +0000413</b></font></td></tr></table><ul>
414
Chris Lattnerae853632002-07-25 19:27:01 +0000415So far, we have seen how the CommandLine library handles builtin types like
416<tt>std::string</tt>, <tt>bool</tt> and <tt>int</tt>, but how does it handle
417things it doesn't know about, like enums or '<tt>int*</tt>'s?<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000418
Chris Lattnerae853632002-07-25 19:27:01 +0000419The answer is that it uses a table driven generic parser (unless you specify
420your own parser, as described in the <a href="#extensionguide">Extension
421Guide</a>). This parser maps literal strings to whatever type is required, are
422requires you to tell it what this mapping should be.<p>
423
424Lets say that we would like to add four optimizations levels to our optimizer,
425using the standard flags "<tt>-g</tt>", "<tt>-O0</tt>", "<tt>-O1</tt>", and
426"<tt>-O2</tt>". We could easily implement this with boolean options like above,
427but there are several problems with this strategy:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000428
429<ol>
Chris Lattnerae853632002-07-25 19:27:01 +0000430<li>A user could specify more than one of the options at a time, for example,
431"<tt>opt -O3 -O2</tt>". The CommandLine library would not be able to catch this
432erroneous input for us.
433
Chris Lattner209c7f42001-07-23 23:03:12 +0000434<li>We would have to test 4 different variables to see which ones are set.
Chris Lattnerae853632002-07-25 19:27:01 +0000435
436<li>This doesn't map to the numeric levels that we want... so we cannot easily
437see if some level &gt;= "<tt>-O1</tt>" is enabled.
438
Chris Lattner209c7f42001-07-23 23:03:12 +0000439</ol><p>
440
Chris Lattnerae853632002-07-25 19:27:01 +0000441To cope with these problems, we can use an enum value, and have the CommandLine
442library fill it in with the appropriate level directly, which is used like
443this:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000444
445<pre>
446enum OptLevel {
447 g, O1, O2, O3
448};
449
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000450<a href="#cl::opt">cl::opt</a>&lt;OptLevel&gt; OptimizationLevel(<a href="#cl::desc">cl::desc</a>("<i>Choose optimization level:</i>"),
451 <a href="#cl::values">cl::values</a>(
Chris Lattnerae853632002-07-25 19:27:01 +0000452 clEnumVal(g , "<i>No optimizations, enable debugging</i>"),
453 clEnumVal(O1, "<i>Enable trivial optimizations</i>"),
454 clEnumVal(O2, "<i>Enable default optimizations</i>"),
455 clEnumVal(O3, "<i>Enable expensive optimizations</i>"),
456 0));
Chris Lattner209c7f42001-07-23 23:03:12 +0000457
458...
Chris Lattnerae853632002-07-25 19:27:01 +0000459 if (OptimizationLevel &gt;= O2) doPartialRedundancyElimination(...);
Chris Lattner209c7f42001-07-23 23:03:12 +0000460...
461</pre><p>
462
Chris Lattnerae853632002-07-25 19:27:01 +0000463This declaration defines a variable "<tt>OptimizationLevel</tt>" of the
464"<tt>OptLevel</tt>" enum type. This variable can be assigned any of the values
465that are listed in the declaration (Note that the declaration list must be
466terminated with the "<tt>0</tt>" argument!). The CommandLine library enforces
467that the user can only specify one of the options, and it ensure that only valid
468enum values can be specified. The "<tt>clEnumVal</tt>" macros ensure that the
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000469command line arguments matched the enum values. With this option added, our
470help output now is:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000471
Chris Lattnerae853632002-07-25 19:27:01 +0000472<pre>
473USAGE: compiler [options] &lt;input file&gt;
Chris Lattner209c7f42001-07-23 23:03:12 +0000474
Chris Lattnerae853632002-07-25 19:27:01 +0000475OPTIONS:
476 Choose optimization level:
477 -g - No optimizations, enable debugging
478 -O1 - Enable trivial optimizations
479 -O2 - Enable default optimizations
480 -O3 - Enable expensive optimizations
481 -f - Overwrite output files
482 -help - display available options (--help-hidden for more)
483 -o &lt;filename&gt; - Specify output filename
484 -quiet - Don't print informational messages
485</pre>
Chris Lattner209c7f42001-07-23 23:03:12 +0000486
Chris Lattnerae853632002-07-25 19:27:01 +0000487In this case, it is sort of awkward that flag names correspond directly to enum
488names, because we probably don't want a enum definition named "<tt>g</tt>" in
489our program. Because of this, we can alternatively write this example like
490this:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000491
492<pre>
493enum OptLevel {
494 Debug, O1, O2, O3
495};
496
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000497<a href="#cl::opt">cl::opt</a>&lt;OptLevel&gt; OptimizationLevel(<a href="#cl::desc">cl::desc</a>("<i>Choose optimization level:</i>"),
498 <a href="#cl::values">cl::values</a>(
Chris Lattnerae853632002-07-25 19:27:01 +0000499 clEnumValN(Debug, "g", "<i>No optimizations, enable debugging</i>"),
500 clEnumVal(O1 , "<i>Enable trivial optimizations</i>"),
501 clEnumVal(O2 , "<i>Enable default optimizations</i>"),
502 clEnumVal(O3 , "<i>Enable expensive optimizations</i>"),
503 0));
Chris Lattner209c7f42001-07-23 23:03:12 +0000504
505...
506 if (OptimizationLevel == Debug) outputDebugInfo(...);
507...
508</pre><p>
509
Chris Lattnerae853632002-07-25 19:27:01 +0000510By using the "<tt>clEnumValN</tt>" macro instead of "<tt>clEnumVal</tt>", we can
511directly specify the name that the flag should get. In general a direct mapping
512is nice, but sometimes you can't or don't want to preserve the mapping, which is
513when you would use it.<p>
514
515
Chris Lattner209c7f42001-07-23 23:03:12 +0000516
517<!-- ======================================================================= -->
518</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0><tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
519<a name="namedalternatives">Named Alternatives
520</b></font></td></tr></table><ul>
521
Chris Lattnerae853632002-07-25 19:27:01 +0000522Another useful argument form is a named alternative style. We shall use this
523style in our compiler to specify different debug levels that can be used.
524Instead of each debug level being its own switch, we want to support the
525following options, of which only one can be specified at a time:
526"<tt>--debug-level=none</tt>", "<tt>--debug-level=quick</tt>",
527"<tt>--debug-level=detailed</tt>". To do this, we use the exact same format as
528our optimization level flags, but we also specify an option name. For this
529case, the code looks like this:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000530
531<pre>
532enum DebugLev {
533 nodebuginfo, quick, detailed
534};
535
536// Enable Debug Options to be specified on the command line
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000537<a href="#cl::opt">cl::opt</a><DebugLev> DebugLevel("<i>debug_level</i>", <a href="#cl::desc">cl::desc</a>("<i>Set the debugging level:</i>"),
538 <a href="#cl::values">cl::values</a>(
Chris Lattnerae853632002-07-25 19:27:01 +0000539 clEnumValN(nodebuginfo, "none", "<i>disable debug information</i>"),
540 clEnumVal(quick, "<i>enable quick debug information</i>"),
541 clEnumVal(detailed, "<i>enable detailed debug information</i>"),
542 0));
Chris Lattner209c7f42001-07-23 23:03:12 +0000543</pre>
544
Chris Lattnerae853632002-07-25 19:27:01 +0000545This definition defines an enumerated command line variable of type "<tt>enum
546DebugLev</tt>", which works exactly the same way as before. The difference here
547is just the interface exposed to the user of your program and the help output by
548the "<tt>--help</tt>" option:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000549
550<pre>
Chris Lattnerae853632002-07-25 19:27:01 +0000551USAGE: compiler [options] &lt;input file&gt;
552
Chris Lattner209c7f42001-07-23 23:03:12 +0000553OPTIONS:
Chris Lattnerae853632002-07-25 19:27:01 +0000554 Choose optimization level:
555 -g - No optimizations, enable debugging
556 -O1 - Enable trivial optimizations
557 -O2 - Enable default optimizations
558 -O3 - Enable expensive optimizations
559 -debug_level - Set the debugging level:
560 =none - disable debug information
561 =quick - enable quick debug information
562 =detailed - enable detailed debug information
563 -f - Overwrite output files
564 -help - display available options (--help-hidden for more)
565 -o &lt;filename&gt; - Specify output filename
566 -quiet - Don't print informational messages
Chris Lattner209c7f42001-07-23 23:03:12 +0000567</pre><p>
568
Chris Lattnerae853632002-07-25 19:27:01 +0000569Again, the only structural difference between the debug level declaration and
570the optimiation level declaration is that the debug level declaration includes
571an option name (<tt>"debug_level"</tt>), which automatically changes how the
572library processes the argument. The CommandLine library supports both forms so
573that you can choose the form most appropriate for your application.<p>
574
Chris Lattner209c7f42001-07-23 23:03:12 +0000575
576
577<!-- ======================================================================= -->
578</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0><tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
Chris Lattnerae853632002-07-25 19:27:01 +0000579<a name="list">Parsing a list of options
Chris Lattner209c7f42001-07-23 23:03:12 +0000580</b></font></td></tr></table><ul>
581
Chris Lattnerae853632002-07-25 19:27:01 +0000582Now that we have the standard run of the mill argument types out of the way,
583lets get a little wild and crazy. Lets say that we want our optimizer to accept
584a <b>list</b> of optimizations to perform, allowing duplicates. For example, we
585might want to run: "<tt>compiler -dce -constprop -inline -dce -strip</tt>". In
586this case, the order of the arguments and the number of appearances is very
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000587important. This is what the "<tt><a href="#cl::list">cl::list</a></tt>"
588template is for. First, start by defining an enum of the optimizations that you
589would like to perform:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000590
591<pre>
592enum Opts {
Chris Lattnerae853632002-07-25 19:27:01 +0000593 // 'inline' is a C++ keyword, so name it 'inlining'
Chris Lattner209c7f42001-07-23 23:03:12 +0000594 dce, constprop, inlining, strip
Chris Lattnerae853632002-07-25 19:27:01 +0000595};
Chris Lattner209c7f42001-07-23 23:03:12 +0000596</pre><p>
597
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000598Then define your "<tt><a href="#cl::list">cl::list</a></tt>" variable:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000599
600<pre>
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000601<a href="#cl::list">cl::list</a>&lt;Opts&gt; OptimizationList(<a href="#cl::desc">cl::desc</a>("<i>Available Optimizations:</i>"),
602 <a href="#cl::values">cl::values</a>(
Chris Lattnerae853632002-07-25 19:27:01 +0000603 clEnumVal(dce , "<i>Dead Code Elimination</i>"),
604 clEnumVal(constprop , "<i>Constant Propogation</i>"),
605 clEnumValN(inlining, "<i>inline</i>", "<i>Procedure Integration</i>"),
606 clEnumVal(strip , "<i>Strip Symbols</i>"),
607 0));
Chris Lattner209c7f42001-07-23 23:03:12 +0000608</pre><p>
609
Chris Lattnerae853632002-07-25 19:27:01 +0000610This defines a variable that is conceptually of the type
611"<tt>std::vector&lt;enum Opts&gt;</tt>". Thus, you can access it with standard
612vector methods:<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000613
614<pre>
Chris Lattnerae853632002-07-25 19:27:01 +0000615 for (unsigned i = 0; i != OptimizationList.size(); ++i)
Chris Lattner209c7f42001-07-23 23:03:12 +0000616 switch (OptimizationList[i])
617 ...
618</pre>
619
Chris Lattnerae853632002-07-25 19:27:01 +0000620... to iterate through the list of options specified.<p>
Chris Lattner209c7f42001-07-23 23:03:12 +0000621
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000622Note that the "<tt><a href="#cl::list">cl::list</a></tt>" template is completely general and may be used
Chris Lattnerae853632002-07-25 19:27:01 +0000623with any data types or other arguments that you can use with the
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000624"<tt><a href="#cl::opt">cl::opt</a></tt>" template. One especially useful way to use a list is to
Chris Lattnerae853632002-07-25 19:27:01 +0000625capture all of the positional arguments together if there may be more than one
626specified. In the case of a linker, for example, the linker takes several
627'<tt>.o</tt>' files, and needs to capture them into a list. This is naturally
628specified as:<p>
Chris Lattner3e5fe172002-04-13 18:35:59 +0000629
630<pre>
631...
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000632<a href="#cl::list">cl::list</a>&lt;std::string&gt; InputFilenames(<a href="#cl::Positional">cl::Positional</a>, <a href="#cl::desc">cl::desc</a>("&lt;Input files&gt;"), <a href="#cl::OneOrMore">cl::OneOrMore</a>);
Chris Lattner3e5fe172002-04-13 18:35:59 +0000633...
634</pre><p>
635
Chris Lattnerae853632002-07-25 19:27:01 +0000636This variable works just like a "<tt>vector&lt;string&gt;</tt>" object. As
637such, accessing the list is simple, just like above. In this example, we used
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000638the <tt><a href="#cl::OneOrMore">cl::OneOrMore</a></tt> modifier to inform the
639CommandLine library that it is an error if the user does not specify any
640<tt>.o</tt> files on our command line. Again, this just reduces the amount of
641checking we have to do.<p>
Chris Lattner3e5fe172002-04-13 18:35:59 +0000642
Chris Lattner3e5fe172002-04-13 18:35:59 +0000643
644
Chris Lattner209c7f42001-07-23 23:03:12 +0000645<!-- *********************************************************************** -->
646</ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0><tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
647<a name="referenceguide">Reference Guide
648</b></font></td></tr></table><ul>
649<!-- *********************************************************************** -->
650
Chris Lattnere76d4ab2002-08-06 19:36:06 +0000651Now that you know the basics of how to use the CommandLine library, this section
652will give you the detailed information you need to tune how command line options
653work, as well as information on more "advanced" command line option processing
654capabilities.<p>
655
656
657<!-- ======================================================================= -->
658</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0><tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
659<a name="positional">Positional Arguments
660</b></font></td></tr></table><ul>
661
662Positional arguments are those arguments that are not named, and are not
663specified with a hyphen. Positional arguments should be used when an option is
664specified by its position alone. For example, the standard Unix <tt>grep</tt>
665tool takes a regular expression argument, and an optional filename to search
666through (which defaults to standard input if a filename is not specified).
667Using the CommandLine library, this would be specified as:<p>
668
669<pre>
670<a href="#cl::opt">cl::opt</a>&lt;string&gt; Regex (<a href="#cl::Positional">cl::Positional</a>, <a href="#cl::desc">cl::desc</a>("<i>&lt;regular expression&gt;</i>"), <a href="#cl::Required">cl::Required</a>);
671<a href="#cl::opt">cl::opt</a>&lt;string&gt; Filename(<a href="#cl::Positional">cl::Positional</a>, <a href="#cl::desc">cl::desc</a>("<i>&lt;input file&gt;</i>"), <a href="#cl::init">cl::init</a>("<i>-</i>"));
672</pre>
673
674Given these two option declarations, the <tt>--help</tt> output for our grep
675replacement would look like this:<p>
676
677<pre>
678USAGE: spiffygrep [options] &lt;regular expression&gt; &lt;input file&gt;
679
680OPTIONS:
681 -help - display available options (--help-hidden for more)
682</pre>
683
684... and the resultant program could be used just like the standard <tt>grep</tt>
685tool.<p>
686
687Positional arguments are sorted by their order of construction. This means that
688command line options will be ordered according to how they are listed in a .cpp
689file, but will not have an ordering defined if they positional arguments are
690defined in multiple .cpp files. The fix for this problem is simply to define
691all of your positional arguments in one .cpp file.<p>
692
693
694
695<!-- _______________________________________________________________________ -->
696</ul><a name="--"><h4><hr size=0>Specifying positional options with hyphens</h4><ul>
697
698Sometimes you may want to specify a value to your positional argument that
699starts with a hyphen (for example, searching for '<tt>-foo</tt>' in a file). At
700first, you will have trouble doing this, because it will try to find an argument
701named '<tt>-foo</tt>', and will fail (and single quotes will not save you).
702Note that the system <tt>grep</tt> has the same problem:<p>
703
704<pre>
705 $ spiffygrep '-foo' test.txt
706 Unknown command line argument '-foo'. Try: spiffygrep --help'
707
708 $ grep '-foo' test.txt
709 grep: illegal option -- f
710 grep: illegal option -- o
711 grep: illegal option -- o
712 Usage: grep -hblcnsviw pattern file . . .
713</pre><p>
714
715The solution for this problem is the same for both your tool and the system
716version: use the '<tt>--</tt>' marker. When the user specifies '<tt>--</tt>' on
717the command line, it is telling the program that all options after the
718'<tt>--</tt>' should be treated as positional arguments, not options. Thus, we
719can use it like this:<p>
720
721<pre>
722 $ spiffygrep -- -foo test.txt
723 ...output...
724</pre><p>
725
726
727
728<!-- _______________________________________________________________________ -->
729</ul><a name="cl::ConsumeAfter"><h4><hr size=0>The <tt>cl::ConsumeAfter</tt> modifier</h4><ul>
730
731The <tt>cl::ConsumeAfter</tt> <a href="#formatting">formatting option</a> is
732used to construct programs that use "interpreter style" option processing. With
733this style of option processing, all arguments specified after the last
734positional argument are treated as special interpreter arguments that are not
735interpreted by the command line argument.<p>
736
737As a concrete example, lets say we are developing a replacement for the standard
738Unix Bourne shell (<tt>/bin/sh</tt>). To run <tt>/bin/sh</tt>, first you
739specify options to the shell itself (like <tt>-x</tt> which turns on trace
740output), then you specify the name of the script to run, then you specify
741arguments to the script. These arguments to the script are parsed by the bourne
742shell command line option processor, but are not interpreted as options to the
743shell itself. Using the CommandLine library, we would specify this as:<p>
744
745<pre>
746<a href="#cl::opt">cl::opt</a>&lt;string&gt; Script(<a href="#cl::Positional">cl::Positional</a>, <a href="#cl::desc">cl::desc</a>("<i>&lt;input script&gt;</i>"), <a href="#cl::init">cl::init</a>("-"));
747<a href="#cl::list">cl::list</a>&lt;string&gt; Argv(<a href="#cl::ConsumeAfter">cl::ConsumeAfter</a>, <a href="#cl::desc">cl::desc</a>("<i>&lt;program arguments&gt;...</i>"));
748<a href="#cl::opt">cl::opt</a>&lt;bool&gt; Trace("<i>x</i>", <a href="#cl::desc">cl::desc</a>("<i>Enable trace output</i>"));
749</pre><p>
750
751which automatically provides the help output:<p>
752
753<pre>
754USAGE: spiffysh [options] &lt;input script&gt; &lt;program arguments&gt;...
755
756OPTIONS:
757 -help - display available options (--help-hidden for more)
758 -x - Enable trace output
759</pre><p>
760
761At runtime, if we run our new shell replacement as '<tt>spiffysh -x test.sh -a
762-x -y bar</tt>', the <tt>Trace</tt> variable will be set to true, the
763<tt>Script</tt> variable will be set to "<tt>test.sh</tt>", and the
764<tt>Argv</tt> list will contain <tt>["-a", "-x", "-y", "bar"]</tt>, because
765they were specified after the last positional argument (which is the script
766name).<p>
767
768There are several limitations to when <tt>cl::ConsumeAfter</tt> options can be
769specified. For example, only one <tt>cl::ConsumeAfter</tt> can be specified per
770program, there must be at least one <a href="#positional">positional
771argument</a> specified, and the <tt>cl::ConsumeAfter</tt> option should be a <a
772href="#cl::list">cl::list</a> option.<p>
773
774
775
776<!-- ======================================================================= -->
777</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0><tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
778<a name="storage">Internal vs External Storage
779</b></font></td></tr></table><ul>
780
781By default, all command line options automatically hold the value that they
782parse from the command line. This is very convenient in the common case,
783especially when combined with the ability to define command line options in the
784files that use them. This is called the internal storage model.<p>
785
786Sometimes, however, it is nice to separate the command line option processing
787code from the storage of the value parsed. For example, lets say that we have a
788'<tt>-debug</tt>' option that we would like to use to enable debug information
789across the entire body of our program. In this case, the boolean value
790controlling the debug code should be globally accessable (in a header file, for
791example) yet the command line option processing code should not be exposed to
792all of these clients (requiring lots of .cpp files to #include
793<tt>CommandLine.h</tt>).<p>
794
795To do this, set up your .h file with your option, like this for example:<p>
796
797<pre>
798<i>// DebugFlag.h - Get access to the '-debug' command line option
799//
800
801// DebugFlag - This boolean is set to true if the '-debug' command line option
802// is specified. This should probably not be referenced directly, instead, use
803// the DEBUG macro below.
804//</i>
805extern bool DebugFlag;
806
807<i>// DEBUG macro - This macro should be used by code to emit debug information.
808// In the '-debug' option is specified on the command line, and if this is a
809// debug build, then the code specified as the option to the macro will be
810// executed. Otherwise it will not be. Example:
811//
812// DEBUG(cerr << "Bitset contains: " << Bitset << "\n");
813//</i>
814<font color=red>#ifdef NDEBUG
815#define DEBUG(X)
816#else
817#define DEBUG(X)</font> \
818 do { if (DebugFlag) { X; } } while (0)
819<font color=red>#endif</font>
820</pre>
821
822This allows clients to blissfully use the <tt>DEBUG()</tt> macro, or the
823<tt>DebugFlag</tt> explicitly if they want to. Now we just need to be able to
824set the <tt>DebugFlag</tt> boolean when the option is set. To do this, we pass
825an additial argument to our command line argument processor, and we specify
826where to fill in with the <a href="#cl::location">cl::location</a> attribute:<p>
827
828<pre>
829bool DebugFlag; <i>// the actual value</i>
830static <a href="#cl::opt">cl::opt</a><bool, true> <i>// The parser</i>
831Debug("<i>debug</i>", <a href="#cl::desc">cl::desc</a>("<i>Enable debug output</i>")</a>, <a href="#cl::Hidden">cl::Hidden</a>,
832 <a href="#cl::location">cl::location</a>(DebugFlag));
833</pre>
834
835In the above example, we specify "<tt>true</tt>" as the second argument to the
836<a href="#cl::opt">cl::opt</a> template, indicating that the template should not
837maintain a copy of the value itself. In addition to this, we specify the <a
838href="#cl::location">cl::location</a> attribute, so that <tt>DebugFlag</tt> is
839automatically set.<p>
840
841
842
843<!-- ======================================================================= -->
844</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0><tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
845<a name="attributes">Option Attributes
846</b></font></td></tr></table><ul>
847
848This section describes the basic attributes that you can specify on options.<p>
849
850<ul>
851
852<li>The option name attribute (which is required for all options, except <a
853href="#positional">positional options</a>) specifies what the option name is.
854This option is specified in simple double quotes:<p>
855
856<a href="#cl::opt">cl::opt</a>&lt;bool&gt; Quiet("<i>quiet</i>");<p>
857
858<li><a name="cl::desc">The <b><tt>cl::desc</tt></b> attribute specifies a
859description for the option to be shown in the <tt>--help</tt> output for the
860program.<p>
861
862<li><a name="cl::value_desc">The <b><tt>cl::value_desc</tt></b> attribute
863specifies a string that can be used to fine tune the <tt>--help</tt> output for
864a command line option. Look <a href="#value_desc_example">here</a> for an
865example.<p>
866
867<li><a name="cl::init">The <b><tt>cl::init</tt></b> attribute specifies an
868inital value for a <a href="#cl::opt">scalar</a> option. If this attribute is
869not specified then the command line option value defaults to the value created
870by the default constructor for the type.<p>
871
872<li><a name="cl::location">The <b><tt>cl::location</tt></b> attribute where to
873store the value for a parsed command line option if using external storage. See
874the section on <a href="#storage">Internal vs External Storage</a> for more
875information.<p>
876
877<li><a name="cl::aliasopt">The <b><tt>cl::aliasopt</tt></b> attribute specifies
878which option a <a href="#cl::alias">cl::alias</a> option is an alias for.<p>
879
880<li><a name="cl::values">The <b><tt>cl::values</tt></b> attribute specifies the
881string-to-value mapping to be used by the generic parser. It takes a <b>null
882terminated</b> list of (option, value, description) triplets that specify the
883option name, the value mapped to, and the description shown in the
884<tt>--help</tt> for the tool. Because the generic parser is used most frequently with enum values, two macros are often useful:<p>
885<ol>
886<li><a name="clEnumVal">The <b><tt>clEnumVal</tt></b> macro is used as a nice
887simple way to specify a triplet for an enum. This macro automatically makes the
888option name be the same as the enum name. The first option to the macro is the
889enum, the second is the description for the command line option.<p> <li><a
890name="clEnumValN">The <b><tt>clEnumValN</tt></b> macro is used to specify macro
891options where the option name doesn't equal the enum name. For this macro, the
892first argument is the enum value, the second is the flag name, and the second is
893the description.<p>
894</ol>
895
896You will get a compile time error if you try to use cl::values with a parser
897that does not support it.<p>
898
899</ul>
900
901
902
903<!-- ======================================================================= -->
904</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0><tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
905<a name="modifiers">Option Modifiers
906</b></font></td></tr></table><ul>
907
908Option modifiers are the flags and expressions that you pass into the
909constructors for <tt><a href="#cl::opt">cl::opt</a></tt> and <tt><a
910href="#cl::list">cl::list</a></tt>. These modifiers give you the ability to
911tweak how options are parsed and how <tt>--help</tt> output is generated to fit
912your application well.<p>
913
914These options naturally fall into four main catagories:<p>
915
916<ol>
917<li><a href="#hiding">Hiding an option from <tt>--help</tt> output</a>
918<li><a href="#numoccurances">Controlling the number of occurances
919 required and allowed</a>
920<li><a href="#valrequired">Controlling whether or not a value must be
921 specified</a>
922<li><a href="#formatting">Controlling other formatting options</a>
923</ol><p>
924
925It is not possible to specify two options from the same catagory (you'll get a
926runtime error) to a single option. The CommandLine library specifies defaults
927for all of these settings that are the most useful in practice and the most
928common, which mean that you usually shouldn't have to worry about these.<p>
929
930
931<!-- _______________________________________________________________________ -->
932</ul><a name="hiding"><h4><hr size=0>Hiding an option from <tt>--help</tt> output</h4><ul>
933
934The <tt>cl::NotHidden</tt>, <tt>cl::Hidden</tt>, and <tt>cl::ReallyHidden</tt>
935modifiers are used to control whether or not an option appears in the
936<tt>--help</tt> and <tt>--help-hidden</tt> output for the compiled program:<p>
937
938<ul>
939
940<a name="cl::NotHidden">The <b><tt>cl::NotHidden</tt></b> modifier (which is the
941default for <tt><a href="#cl::opt">cl::opt</a></tt> and <tt><a
942href="#cl::list">cl::list</a></tt> options), indicates the option is to appear
943in both help listings.<p>
944
945<a name="cl::Hidden">The <b><tt>cl::Hidden</tt></b> modifier (which is the
946default for <tt><a href="#cl::alias">cl::alias</a></tt> options), indicates that
947the option should not appear in the <tt>--help</tt> output, but should appear in
948the <tt>--help-hidden</tt> output.<p>
949
950<a name="cl::ReallyHidden">The <b><tt>cl::ReallyHidden</tt></b> modifier,
951indicates that the option should not appear in any help output.<p>
952</ul>
953
954<!-- _______________________________________________________________________ -->
955</ul><a name="numoccurances"><h4><hr size=0>Controlling the number of occurances required and allowed</h4><ul>
956
957This group of options is used to control how many time an option is allowed (or
958required) to be specified on the command line of your program. Specifying a
959value for this setting allows the CommandLine library to do error checking for
960you.<p>
961
962The allowed values for this option group are:<p>
963
964<ul>
965<a name="cl::Optional">The <b><tt>cl::Optional</tt></b> modifier (which is the
966default for the <tt><a href="#cl::opt">cl::opt</a></tt> and <tt><a
967href="#cl::alias">cl::alias</a></tt> classes) indicates that your program will
968allow either zero or one occurance of the option to be specified.<p>
969
970<a name="cl::ZeroOrMore">The <b><tt>cl::ZeroOrMore</tt></b> modifier (which is
971the default for the <tt><a href="#cl::list">cl::list</a></tt> class) indicates
972that your program will allow the option to be specified zero or more times.<p>
973
974<a name="cl::Required">The <b><tt>cl::Required</tt></b> modifier indicates that
975the specified option must be specified exactly one time.<p>
976
977<a name="cl::OneOrMore">The <b><tt>cl::OneOrMore</tt></b> modifier indicates
978that the option must be specified at least one time.<p>
979
980The <b><tt>cl::ConsumeAfter</tt></b> modifier is described in the <a
981href="#positional">Positional arguments section</a><p>
982
983</ul>
984
985If an option is not specified, then the value of the option is equal to the
986value specified by the <tt><a href="#cl::init">cl::init</a></tt> attribute. If
987the <tt><a href="#cl::init">cl::init</a></tt> attribute is not specified, the
988option value is initialized with the default constructor for the data type.<p>
989
990If an option is specified multiple times for an option of the <tt><a
991href="#cl::opt">cl::opt</a></tt> class, only the last value will be retained.<p>
992
993
994<!-- _______________________________________________________________________ -->
995</ul><a name="valrequired"><h4><hr size=0>Controlling whether or not a value must be specified</h4><ul>
996
997This group of options is used to control whether or not the option allows a
998value to be present. In the case of the CommandLine library, a value is either
999specified with an equal sign (e.g. '<tt>-index-depth=17</tt>') or as a trailing
1000string (e.g. '<tt>-o a.out</tt>').<p>
1001
1002The allowed values for this option group are:<p>
1003
1004<ul>
1005<a name="cl::ValueOptional">The <b><tt>cl::ValueOptional</tt></b> modifier
1006(which is the default for <tt>bool</tt> typed options) specifies that it is
1007acceptable to have a value, or not. A boolean argument can be enabled just by
1008appearing on the command line, or it can have an explicit '<tt>-foo=true</tt>'.
1009If an option is specified with this mode, it is illegal for the value to be
1010provided without the equal sign. Therefore '<tt>-foo true</tt>' is illegal. To
1011get this behavior, you must use the <a
1012href="#cl::ValueRequired">cl::ValueRequired</a> modifier.<p>
1013
1014<a name="cl::ValueRequired">The <b><tt>cl::ValueRequired</tt></b> modifier
1015(which is the default for all other types except for <a
1016href="#onealternative">unnamed alternatives using the generic parser</a>)
1017specifies that a value must be provided. This mode informs the command line
1018library that if an option is not provides with an equal sign, that the next
1019argument provided must be the value. This allows things like '<tt>-o
1020a.out</tt>' to work.<p>
1021
1022<a name="cl::ValueDisallowed">The <b><tt>cl::ValueDisallowed</tt></b> modifier
1023(which is the default for <a href="#onealternative">unnamed alternatives using
1024the generic parser</a>) indicates that it is a runtime error for the user to specify a value. This can be provided to disallow users from providing options to boolean options (like '<tt>-foo=true</tt>').<p>
1025
1026</ul>
1027
1028In general, the default values for this option group work just like you would
1029want them to. As mentioned above, you can specify the <a
1030href="#cl::ValueDisallowed">cl::ValueDisallowed</a> modifier to a boolean
1031argument to restrict your command line parser. These options are mostly useful
1032when <a href="#extensionguide">extending the library</a>.<p>
1033
1034
1035
1036<!-- _______________________________________________________________________ -->
1037</ul><a name="formatting"><h4><hr size=0>Controlling other formatting options</h4><ul>
1038
1039The formatting option group is used to specify that the command line option has
1040special abilities and is otherwise different from other command line arguments.
1041As usual, you can only specify at most one of these arguments.<p>
1042
1043<ul>
1044<a name="cl::NormalFormatting">The <b><tt>cl::NormalFormatting</tt></b> modifier
1045(which is the default all options) specifies that this option is "normal".<p>
1046
1047<a name="cl::Positional">The <b><tt>cl::Positional</tt></b> modifier specifies
1048that this is a positional argument, that does not have a command line option
1049associated with it. See the <a href="#positional">Positional Arguments</a>
1050section for more information.<p>
1051
1052The <b><a href="#cl::ConsumeAfter"><tt>cl::ConsumeAfter</tt></a></b> modifier
1053specifies that this option is used to capture "interpreter style" arguments. See <a href="#cl::ConsumeAfter">this section for more information</a>.<p>
1054
1055
1056<a name="cl::Prefix">The <b><tt>cl::Prefix</tt></b> modifier specifies that this
1057option prefixes its value. With 'Prefix' options, there is no equal sign that
1058seperates the value from the option name specified. This is useful for
1059processing odd arguments like '<tt>-lmalloc -L/usr/lib'</tt> in a linker tool.
1060Here, the '<tt>l</tt>' and '<tt>L</tt>' options are normal string (list)
1061options, that have the <a href="#cl::Prefix">cl::Prefix</a> modifier added to
1062allow the CommandLine library to recognize them. Note that <a
1063href="#cl::Prefix">cl::Prefix</a> options must not have the <a
1064href="#cl::ValueDisallowed">cl::ValueDisallowed</a> modifier specified.<p>
1065
1066<a name="cl::Grouping">The <b><tt>cl::Grouping</tt></b> modifier is used to
1067implement unix style tools (like <tt>ls</tt>) that have lots of single letter
1068arguments, but only require a single dash. For example, the '<tt>ls -labF</tt>'
1069command actually enables four different options, all of which are single
1070letters. Note that <a href="#cl::Grouping">cl::Grouping</a> options cannot have
1071values.<p>
1072
1073</ul>
1074
1075The CommandLine library does not restrict how you use the <a
1076href="#cl::Prefix">cl::Prefix</a> or <a href="#cl::Grouping">cl::Grouping</a>
1077modifiers, but it is possible to specify ambiguous argument settings. Thus, it
1078is possible to have multiple letter options that are prefix or grouping options,
1079and they will still work as designed.<p>
1080
1081To do this, the CommandLine library uses a greedy algorithm to parse the input
1082option into (potentially multiple) prefix and grouping options. The strategy
1083basically looks like this:<p>
1084
1085<tt>parse(string OrigInput) {</tt>
1086<ol>
1087<li><tt>string input = OrigInput;</tt>
1088<li><tt>if (isOption(input)) return getOption(input).parse();</tt>&nbsp;&nbsp;&nbsp;&nbsp;<i>// Normal option</i>
1089<li><tt>while (!isOption(input) &amp;&amp; !input.empty()) input.pop_back();</tt>&nbsp;&nbsp;&nbsp;&nbsp;<i>// Remove the last letter</i>
1090<li><tt>if (input.empty()) return error();</tt>&nbsp;&nbsp;&nbsp;&nbsp;<i>// No matching option</i>
1091<li><tt>if (getOption(input).isPrefix())<br>
1092&nbsp;&nbsp;return getOption(input).parse(input);</tt>
1093<li><tt>while (!input.empty()) {&nbsp;&nbsp;&nbsp;&nbsp;<i>// Must be grouping options</i><br>
1094&nbsp;&nbsp;getOption(input).parse();<br>
1095&nbsp;&nbsp;OrigInput.erase(OrigInput.begin(), OrigInput.begin()+input.length());<br>
1096&nbsp;&nbsp;input = OrigInput;<br>
1097&nbsp;&nbsp;while (!isOption(input) &amp;&amp; !input.empty()) input.pop_back();<br>
1098}</tt>
1099<li><tt>if (!OrigInput.empty()) error();</tt>
1100</tt>
1101
1102</ol>
1103<tt>}</tt><p>
1104
1105
1106<!-- ======================================================================= -->
1107</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0><tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
1108<a name="optionclasses">Option Classes
1109</b></font></td></tr></table><ul>
1110
1111Despite all of the builtin flexibility, the CommandLine option library really
1112only consists of three main classes: <a href="#cl::opt">cl::opt</a>, <a
1113href="#cl::list">cl::list</a>, and <a href="#cl::alias">cl::alias</a>. This
1114section describes these three classes in detail.<p>
1115
1116<!-- _______________________________________________________________________ -->
1117</ul><a name="cl::opt"><h4><hr size=0>The <tt>cl::opt</tt> class</h4><ul>
1118
1119The <tt>cl::opt</tt> class is the class used to represent scalar command line
1120options, and is the one used most of the time. It is a templated class which
1121can take up to three arguments (all except for the first have default values
1122though):<p>
1123
1124<pre>
1125namespace cl {
1126 template &lt;class DataType, bool ExternalStorage = false,
1127 class ParserClass = parser&lt;DataType&gt; &gt;
1128 class opt;
1129}
1130</pre><p>
1131
1132The first template argument specifies what underlying data type the command line
1133argument is, and is used to select a default parser implementation. The second
1134template argument is used to specify whether the option should contain the
1135storage for the option (the default) or whether external storage should be used
1136to contain the value parsed for the option (see <a href="#storage">Internal vs
1137External Storage</a> for more information).<p>
1138
1139The third template argument specifies which parser to use. The default value
1140selects an instantiation of the <tt>parser</tt> class based on the underlying
1141data type of the option. In general, this default works well for most
1142applications, so this option is only used when using a <a
1143href="#customparser">custom parser</a>.<p>
1144
1145
1146<!-- _______________________________________________________________________ -->
1147</ul><a name="cl::list"><h4><hr size=0>The <tt>cl::list</tt> class</h4><ul>
1148
1149The <tt>cl::list</tt> class is the class used to represent a list of command
1150line options. It too is a templated class which can take up to three
1151arguments:<p>
1152
1153<pre>
1154namespace cl {
1155 template &lt;class DataType, class Storage = bool,
1156 class ParserClass = parser&lt;DataType&gt; &gt;
1157 class list;
1158}
1159</pre><p>
1160
1161This class works the exact same as the <a href="#cl::opt"><tt>cl::opt</tt></a>
1162class, except that the second argument is the <b>type</b> of the external
1163storage, not a boolean value. For this class, the marker type '<tt>bool</tt>'
1164is used to indicate that internal storage should be used.<p>
1165
1166
1167<!-- _______________________________________________________________________ -->
1168</ul><a name="cl::alias"><h4><hr size=0>The <tt>cl::alias</tt> class</h4><ul>
1169
1170The <tt>cl::alias</tt> class is a nontemplated class that is used to form
1171aliases for other arguments.<p>
1172
1173<pre>
1174namespace cl {
1175 class alias;
1176}
1177</pre></p>
1178
1179The <a href="#cl::aliasopt"><tt>cl::aliasopt</tt></a> attribute should be used
1180to specify which option this is an alias for. Alias arguments default to being
1181<a href="#cl::Hidden">Hidden</a>, and use the aliased options parser to do the
1182conversion from string to data.<p>
1183
1184
1185<!-- ======================================================================= -->
1186</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0><tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
1187<a name="builtinparsers">Builtin parsers
1188</b></font></td></tr></table><ul>
1189
1190Parsers control how the string value taken from the command line is translated
1191into a typed value, suitable for use in a C++ program. By default, the
1192CommandLine library uses an instance of <tt>parser&lt;type&gt;</tt> if the
1193command line option specifies that it uses values of type '<tt>type</tt>'.
1194Because of this, custom option processing is specified with specializations of
1195the '<tt>parser</tt>' class.<p>
1196
1197The CommandLine library provides the following builtin parser specializations,
1198which are sufficient for most applications. It can, however, also be extended to
1199work with new data types and new ways of interpreting the same data. See the <a
1200href="#customparser">Writing a Custom Parser</a> for more details on this type
1201of library extension.<p>
1202
1203<li><a name="genericparser">The <b>generic <tt>parser&lt;t&gt;</tt> parser</b>
1204can be used to map strings values to any data type, through the use of the <a
1205href="#cl::values">cl::values</a> property, which specifies the mapping
1206information. The most common use of this parser is for parsing enum values,
1207which allows you to use the CommandLine library for all of the error checking to
1208make sure that only valid enum values are specified (as opposed to accepting
1209arbitrary strings). Despite this, however, the generic parser class can be used
1210for any data type.<p>
1211
1212<li><a name="boolparser">The <b><tt>parser&lt;bool&gt;</tt> specialization</b>
1213is used to convert boolean strings to a boolean value. Currently accepted
1214strings are "<tt>true</tt>", "<tt>TRUE</tt>", "<tt>True</tt>", "<tt>1</tt>",
1215"<tt>false</tt>", "<tt>FALSE</tt>", "<tt>False</tt>", and "<tt>0</tt>".<p>
1216
1217<li><a name="stringparser">The <b><tt>parser&lt;string&gt;</tt> specialization</b> simply stores the parsed string into the string value specified. No conversion or modification of the data is performed.<p>
1218
1219<li><a name="intparser">The <b><tt>parser&lt;int&gt;</tt> specialization</b>
1220uses the C <tt>strtol</tt> function to parse the string input. As such, it will
1221accept a decimal number (with an optional '+' or '-' prefix) which must start
1222with a non-zero digit. It accepts octal numbers, which are identified with a
1223'<tt>0</tt>' prefix digit, and hexadecimal numbers with a prefix of
1224'<tt>0x</tt>' or '<tt>0X</tt>'.<p>
1225
1226<li><a name="doubleparser">The <b><tt>parser&lt;double&gt;</tt></b> and
1227<b><tt>parser&lt;float&gt;</tt> specializations</b> use the standard C
1228<tt>strtod</tt> function to convert floating point strings into floating point
1229values. As such, a broad range of string formats is supported, including
1230exponential notation (ex: <tt>1.7e15</tt>) and properly supports locales.
1231<p>
1232
Chris Lattner209c7f42001-07-23 23:03:12 +00001233
1234
1235<!-- *********************************************************************** -->
1236</ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0><tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
1237<a name="extensionguide">Extension Guide
1238</b></font></td></tr></table><ul>
1239<!-- *********************************************************************** -->
1240
Chris Lattnere76d4ab2002-08-06 19:36:06 +00001241TODO
Chris Lattner209c7f42001-07-23 23:03:12 +00001242
Chris Lattnere76d4ab2002-08-06 19:36:06 +00001243<!-- ======================================================================= -->
1244</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0><tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
1245<a name="customparser">Writing a custom parser
1246</b></font></td></tr></table><ul>
1247
1248
1249
1250<!-- ======================================================================= -->
1251</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0><tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
1252<a name="explotingexternal">Exploiting external storage
1253</b></font></td></tr></table><ul>
1254
1255
1256
1257<!-- ======================================================================= -->
1258</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0><tr><td>&nbsp;</td><td width="100%">&nbsp; <font color="#EEEEFF" face="Georgia,Palatino"><b>
1259<a name="dynamicopts">Dynamically adding command line options
1260</b></font></td></tr></table><ul>
1261
1262
Chris Lattner209c7f42001-07-23 23:03:12 +00001263
1264
1265
1266<!-- *********************************************************************** -->
1267</ul>
1268<!-- *********************************************************************** -->
1269
1270<hr>
1271<font size=-1>
1272<address><a href="mailto:sabre@nondot.org">Chris Lattner</a></address>
1273<!-- Created: Tue Jan 23 15:19:28 CST 2001 -->
1274<!-- hhmts start -->
Chris Lattnere76d4ab2002-08-06 19:36:06 +00001275Last modified: Tue Aug 6 14:34:47 CDT 2002
Chris Lattner209c7f42001-07-23 23:03:12 +00001276<!-- hhmts end -->
1277</font>
1278</body></html>