Skip to content

Commit 0c7e214

Browse files
committed
Better documentation.
1 parent d5688cb commit 0c7e214

4 files changed

Lines changed: 40 additions & 43 deletions

File tree

src/site/xdoc/index.xml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
<document>
2121

2222
<properties>
23-
<title>Home</title>
23+
<title>Apache Commons CLI</title>
2424
<author email="dev@commons.apache.org">commons-dev</author>
2525
</properties>
2626

2727
<body>
28-
<section name="Commons CLI">
28+
<section name="Apache Commons CLI">
2929
<p>
3030
The Apache Commons CLI library provides an API for parsing command line options passed to programs.
3131
It's also able to print help messages detailing the options available for a command line tool.
@@ -61,15 +61,6 @@ usage: ls
6161
</p>
6262
</section>
6363

64-
<section name="CLI 2?">
65-
<p>
66-
Commons CLI 1.0 was formed from the merger of ideas and code from three different libraries -
67-
Werken, Avalon and Optz. In dealing with the bugs and the feature requests a freshly designed and not
68-
backwards compatible CLI 2 was created in 2004, but never finished or released.
69-
</p>
70-
<p>The current plan is to continue to maintain the 1.x line. The CLI2 work may be found in the Commons Sandbox. </p>
71-
</section>
72-
7364
<section name="Documentation">
7465
<p>
7566
A full <a href="introduction.html">User's Guide</a> is available
@@ -112,6 +103,15 @@ usage: ls
112103
</p>
113104
</section>
114105

106+
<section name="CLI 2?">
107+
<p>
108+
Commons CLI 1.0 was formed from the merger of ideas and code from three different libraries -
109+
Werken, Avalon and Optz. In dealing with the bugs and the feature requests a freshly designed and not
110+
backwards compatible CLI 2 was created in 2004, but never finished or released.
111+
</p>
112+
<p>The current plan is to continue to maintain the 1.x line. The CLI2 work may be found in the Commons Sandbox. </p>
113+
</section>
114+
115115
</body>
116116

117117
</document>

src/site/xdoc/introduction.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@
2121

2222
<properties>
2323
<author email="dev@commons.apache.org">commons-dev</author>
24-
<title>Introduction</title>
24+
<title>Introducing Apache Commons CLI</title>
2525
</properties>
2626

2727
<body>
28-
<section name="Introduction">
28+
<section name="Introducing Apache Commons CLI">
2929
<p>
3030
There are three stages to command line processing. They are the
3131
definition, parsing and interrogation stages. The following
3232
sections will discuss each of these stages in turn, and discuss how
3333
to implement them with CLI.
3434
</p>
3535
</section>
36-
<section name="Definition Stage">
36+
<section name="The Definition Stage">
3737
<p>
3838
Each command line must define the set of options that will be used
3939
to define the interface to the application.
@@ -57,7 +57,7 @@
5757
instance.
5858
</p>
5959
</section>
60-
<section name="Parsing Stage">
60+
<section name="The Parsing Stage">
6161
<p>
6262
The parsing stage is where the text passed into the
6363
application via the command line is processed. The text is
@@ -78,7 +78,7 @@
7878
instance.
7979
</p>
8080
</section>
81-
<section name="Interrogation Stage">
81+
<section name="The Interrogation Stage">
8282
<p>
8383
The interrogation stage is where the application queries the
8484
<code>CommandLine</code> to decide what execution branch to

src/site/xdoc/properties.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121

2222
<properties>
2323
<author email="dev@commons.apache.org">commons-dev</author>
24-
<title>Option Properties</title>
24+
<title>Defining Option Properties</title>
2525
</properties>
2626

2727
<body>
28-
<section name="Option Properties">
28+
<section name="Defining Option Properties">
2929
<p>
3030
The following are the properties that each
3131
<a href="api-release/org/apache/commons/cli/Option.html">Option</a> has. All of these

src/site/xdoc/usage.xml

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121

2222
<properties>
2323
<author email="dev@commons.apache.org">commons-dev</author>
24-
<title>Usage Scenarios</title>
24+
<title>Using Apache Commons CLI</title>
2525
</properties>
2626

2727
<body>
28-
<section name="Usage Scenarios">
28+
<section name="Using Apache Commons CLI">
2929
<p>
3030
The following sections describe some example scenarios on how to
3131
use CLI in applications.
@@ -43,7 +43,7 @@
4343
also printed.
4444
</p>
4545
</subsection>
46-
<subsection name="Create the Options">
46+
<subsection name="Creating the Options">
4747
<p>
4848
An <a href="api-release/org/apache/commons/cli/Options.html">
4949
Options</a> object must be created and the <code>Option</code> must be
@@ -92,7 +92,7 @@ else {
9292
}</source>
9393
<p>
9494
<h4>Note.</h4>
95-
As of version 1.5-SNAPSHOT (as of 7/31/2017), the
95+
As of version 1.5, the
9696
<code>DefaultParser</code>'s constructor now has an override with
9797
the signature <code>DefaultParser(final boolean allowPartialMatching)</code>.
9898
Given the following code:
@@ -139,9 +139,8 @@ else {
139139
</subsection>
140140
</section>
141141

142-
<section name="Ant Example">
142+
<section name="Using Ant as an Example">
143143
<p>
144-
One of the most ubiquitous Java applications
145144
<a href="http://ant.apache.org/">Ant</a> will be used
146145
here to illustrate how to create the <code>Options</code> required. The following
147146
is the help output for Ant.
@@ -162,7 +161,7 @@ else {
162161
-D&lt;property>=&lt;value&gt; use value for given property
163162
-find &lt;file&gt; search for buildfile towards the root of the
164163
filesystem and use it</source>
165-
<subsection name="Boolean Options">
164+
<subsection name="Defining Boolean Options">
166165
<p>
167166
Lets create the boolean options for the application as they
168167
are the easiest to create. For clarity the constructors for
@@ -177,7 +176,7 @@ Option debug = new Option("debug", "print debugging information");
177176
Option emacs = new Option("emacs",
178177
"produce logging information without adornments");</source>
179178
</subsection>
180-
<subsection name="Argument Options">
179+
<subsection name="Defining Argument Options">
181180
<p>
182181
The argument options are created using the <code>Option#Builder</code>.
183182
</p>
@@ -213,22 +212,21 @@ Option find = Option.builde("find")
213212
+ "root of the filesystem and use it")
214213
.build();</source>
215214
</subsection>
216-
<subsection name="Java Property Option">
215+
<subsection name="Defining Java Property Option">
217216
<p>
218217
The last option to create is the Java property and it is also created
219218
using the OptionBuilder.
220219
</p>
221-
<source>Option property = OptionBuilder.withArgName("property=value")
222-
.hasArgs(2)
223-
.withValueSeparator()
224-
.withDescription("use value for given property")
225-
.create("D");</source>
220+
<source>Option property = Option property = Option.builder("D")
221+
.hasArgs()
222+
.valueSeparator('=')
223+
.build();</source>
226224

227225
The map of properties specified by this option can later be retrieved by
228226
calling <code>getOptionProperties("D")</code> on the <code>CommandLine</code>.
229227

230228
</subsection>
231-
<subsection name="Create the Options">
229+
<subsection name="Creating the Options">
232230
<p>
233231
Now that we have created each
234232
<a href="api-release/org/apache/commons/cli/Option.html">Option</a> we need
@@ -258,7 +256,7 @@ options.addOption(property);</source>
258256
parse the command line arguments.
259257
</p>
260258
</subsection>
261-
<subsection name="Create the Parser">
259+
<subsection name="Creating the Parser">
262260
<p>
263261
We now need to create a <code>CommandLineParser</code>. This will parse the command
264262
line arguments, using the rules specified by the <code>Options</code> and
@@ -289,7 +287,7 @@ if(line.hasOption("buildfile")) {
289287
this.buildfile = line.getOptionValue("buildfile");
290288
}</source>
291289
</subsection>
292-
<subsection name="Usage/Help">
290+
<subsection name="Displaying Usage and Help">
293291
<p>
294292
CLI also provides the means to automatically generate usage
295293
and help information. This is achieved with the
@@ -324,7 +322,7 @@ formatter.printHelp("ant", options);</source>
324322
</subsection>
325323
</section>
326324

327-
<section name="ls Example">
325+
<section name="Creating an ls Example">
328326
<p>
329327
One of the most widely used command line applications in the *nix world
330328
is <code>ls</code>. Due to the large number of options required for <code>ls</code>
@@ -337,7 +335,7 @@ Sort entries alphabetically if none of -cftuSUX nor --sort.
337335

338336
-a, --all do not hide entries starting with .
339337
-A, --almost-all do not list implied . and ..
340-
-b, --escape print octal escapes for nongraphic characters
338+
-b, --escape print octal escapes for non-graphic characters
341339
--block-size=SIZE use SIZE-byte blocks
342340
-B, --ignore-backups do not list implied entries ending with ~
343341
-c with -lt: sort by, and show, ctime (time of last
@@ -356,14 +354,13 @@ CommandLineParser parser = new DefaultParser();
356354
Options options = new Options();
357355
options.addOption("a", "all", false, "do not hide entries starting with .");
358356
options.addOption("A", "almost-all", false, "do not list implied . and ..");
359-
options.addOption("b", "escape", false, "print octal escapes for nongraphic "
357+
options.addOption("b", "escape", false, "print octal escapes for non-graphic "
360358
+ "characters");
361-
options.addOption(OptionBuilder.withLongOpt("block-size")
362-
.withDescription("use SIZE-byte blocks")
359+
options.addOption(Option.builder("SIZE").longOpt("block-size")
360+
.desc("use SIZE-byte blocks")
363361
.hasArg()
364-
.withArgName("SIZE")
365-
.create());
366-
options.addOption("B", "ignore-backups", false, "do not list implied entried "
362+
.build());
363+
options.addOption("B", "ignore-backups", false, "do not list implied entries "
367364
+ "ending with ~");
368365
options.addOption("c", false, "with -lt: sort by, and show, ctime (time of last "
369366
+ "modification of file status information) with "

0 commit comments

Comments
 (0)