Skip to content

Commit efe6a40

Browse files
author
John Keyes
committed
update documentation for simple options
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/cli/trunk@129775 13f79535-47bb-0310-9956-ffa450edef68
1 parent 0947465 commit efe6a40

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

xdocs/usage.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
Options options = new Options();
3636

3737
// add t option
38-
options.addOption('t', false, "display current time");</source>
38+
options.addOption("t", false, "display current time");</source>
3939
<p>
4040
The <code>addOption</code> method has three parameters. The first
41-
parameter is a <code>char</code> that represents the option. The
41+
parameter is a <code>java.lang.String</code> that represents the option. The
4242
second paramter is a <code>boolean</code> that specifies whether the
4343
option requires an argument or not. In the case of a boolean option
4444
(sometimes referred to as a flag) an argument value is not present so
@@ -59,11 +59,11 @@ CommandLine cmd = options.parse(args);</source>
5959
this we will interrogate the
6060
<a href="apidocs/org/apache/commons/cli/CommandLine.html"><code>CommandLine</code>
6161
</a> object. The <code>hasOption</code> method takes a
62-
<code>char</code> parameter and returns true if the option represented
63-
by the <code>char</code> is present, otherwise it returns false.
62+
<code>java.lang.String</code> parameter and returns true if the option represented
63+
by the <code>java.lang.String</code> is present, otherwise it returns false.
6464
</p>
6565
<source>
66-
if(cmd.hasOption('t')) {
66+
if(cmd.hasOption("t")) {
6767
// print the date and time
6868
}
6969
else {
@@ -79,7 +79,7 @@ else {
7979
</p>
8080
<source>
8181
// add c option
82-
options.addOption('c', true, "country code");</source>
82+
options.addOption("c", true, "country code");</source>
8383
<p>
8484
The second parameter is true this time. This specifies that the
8585
<code>c</code> option requires an argument value. If the required option
@@ -94,7 +94,7 @@ options.addOption('c', true, "country code");</source>
9494
</p>
9595
<source>
9696
// get c option value
97-
String countryCode = options.getOptionValue('c');
97+
String countryCode = options.getOptionValue("c");
9898

9999
if(countryCode == null) {
100100
// print default date

0 commit comments

Comments
 (0)