You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by jk...@apache.org on 2002/06/20 23:32:38 UTC
cvs commit: jakarta-commons/cli/xdocs usage.xml
jkeyes 2002/06/20 14:32:38
Modified: cli/xdocs usage.xml
Log:
update documentation for simple options
Revision Changes Path
1.2 +7 -7 jakarta-commons/cli/xdocs/usage.xml
Index: usage.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/cli/xdocs/usage.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- usage.xml 10 Jun 2002 18:20:39 -0000 1.1
+++ usage.xml 20 Jun 2002 21:32:38 -0000 1.2
@@ -35,10 +35,10 @@
Options options = new Options();
// add t option
-options.addOption('t', false, "display current time");</source>
+options.addOption("t", false, "display current time");</source>
<p>
The <code>addOption</code> method has three parameters. The first
- parameter is a <code>char</code> that represents the option. The
+ parameter is a <code>java.lang.String</code> that represents the option. The
second paramter is a <code>boolean</code> that specifies whether the
option requires an argument or not. In the case of a boolean option
(sometimes referred to as a flag) an argument value is not present so
@@ -59,11 +59,11 @@
this we will interrogate the
<a href="apidocs/org/apache/commons/cli/CommandLine.html"><code>CommandLine</code>
</a> object. The <code>hasOption</code> method takes a
- <code>char</code> parameter and returns true if the option represented
- by the <code>char</code> is present, otherwise it returns false.
+ <code>java.lang.String</code> parameter and returns true if the option represented
+ by the <code>java.lang.String</code> is present, otherwise it returns false.
</p>
<source>
-if(cmd.hasOption('t')) {
+if(cmd.hasOption("t")) {
// print the date and time
}
else {
@@ -79,7 +79,7 @@
</p>
<source>
// add c option
-options.addOption('c', true, "country code");</source>
+options.addOption("c", true, "country code");</source>
<p>
The second parameter is true this time. This specifies that the
<code>c</code> option requires an argument value. If the required option
@@ -94,7 +94,7 @@
</p>
<source>
// get c option value
-String countryCode = options.getOptionValue('c');
+String countryCode = options.getOptionValue("c");
if(countryCode == null) {
// print default date
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>