|
17 | 17 | specific language governing permissions and limitations |
18 | 18 | under the License. |
19 | 19 | --> |
20 | | -<document> |
21 | | - |
| 20 | +<document xmlns="http://maven.apache.org/XDOC/2.0" |
| 21 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 22 | + xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd"> |
22 | 23 | <properties> |
23 | | - <author email="dev@commons.apache.org">commons-dev</author> |
24 | 24 | <title>Using Apache Commons CLI</title> |
| 25 | + <author email="dev@commons.apache.org">Apache Commons Team</author> |
25 | 26 | </properties> |
26 | 27 |
|
27 | 28 | <body> |
|
91 | 92 | // print the date |
92 | 93 | }</source> |
93 | 94 | <p> |
94 | | - <h4>Note.</h4> |
| 95 | + <em>Note.</em> |
| 96 | + </p> |
| 97 | + <p> |
95 | 98 | As of version 1.5, the |
96 | 99 | <code>DefaultParser</code>'s constructor now has an override with |
97 | 100 | the signature <code>DefaultParser(final boolean allowPartialMatching)</code>. |
@@ -221,10 +224,10 @@ Option find = Option.builder("find") |
221 | 224 | .hasArgs() |
222 | 225 | .valueSeparator('=') |
223 | 226 | .build();</source> |
224 | | - |
| 227 | + <p> |
225 | 228 | The map of properties specified by this option can later be retrieved by |
226 | 229 | calling <code>getOptionProperties("D")</code> on the <code>CommandLine</code>. |
227 | | - |
| 230 | + </p> |
228 | 231 | </subsection> |
229 | 232 | <subsection name="Creating the Options"> |
230 | 233 | <p> |
@@ -418,25 +421,27 @@ public static void main(String[] args) { |
418 | 421 | } </source> |
419 | 422 | <p> |
420 | 423 | The value types natively supported by commons-cli are: |
421 | | - <ul> |
422 | | - <li>Object.class - The string value must be the name of a class with a no argument constructor</li> |
423 | | - <li>Class.class - The string value must be the name of a class</li> |
424 | | - <li>Date.class - The string value must be a date parsable by <code>new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy")</code></li> |
425 | | - <li>File.class - The string value is the name of the file.</li> |
426 | | - <li>Path.class - The string value is the name of a Path.</li> |
427 | | - <li>Number.class - The string value is a number representation can can be converted into an Integer or a Double.</li> |
428 | | - <li>URL.class - The string value is the textual representation of a URL</li> |
429 | | - <li>FileInputStream.class - The string value is passed to <code>new FileInputStream(s)</code>.</li> |
430 | | - <li>Long.class - The string value is a valid argument to <code>Long.parseLong()</code>.</li> |
431 | | - <li>Integer.class - The string value is a valid argument to <code>Integer.parseInt()</code>.</li> |
432 | | - <li>Short.class - The string value is a valid argument to <code>Short.parseShort()</code>.</li> |
433 | | - <li>Byte.class - The string value is a valid argument to <code>Byte.parseByte()</code>.</li> |
434 | | - <li>Character.class - The string value is either a UTF-8 encoding for a character (e.g. "\\u0124") or the first character from the String."</li> |
435 | | - <li>Double.class - The string value is a valid argument to <code>Double.parseDouble()</code>.</li> |
436 | | - <li>Float.class - The string value is a valid argument to <code>Float.parseFloat()</code>.</li> |
437 | | - <li>BigInteger.class - The string value is a valid argument to <code>new BigInteger(s)</code>.</li> |
438 | | - <li>BigDecimal.class - The string value is a valid argument to <code>new BigDecimal(s)</code>.</li> |
439 | | - </ul> |
| 424 | + </p> |
| 425 | + <ul> |
| 426 | + <li>Object.class - The string value must be the name of a class with a no argument constructor</li> |
| 427 | + <li>Class.class - The string value must be the name of a class</li> |
| 428 | + <li>Date.class - The string value must be a date parsable by <code>new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy")</code></li> |
| 429 | + <li>File.class - The string value is the name of the file.</li> |
| 430 | + <li>Path.class - The string value is the name of a Path.</li> |
| 431 | + <li>Number.class - The string value is a number representation can can be converted into an Integer or a Double.</li> |
| 432 | + <li>URL.class - The string value is the textual representation of a URL</li> |
| 433 | + <li>FileInputStream.class - The string value is passed to <code>new FileInputStream(s)</code>.</li> |
| 434 | + <li>Long.class - The string value is a valid argument to <code>Long.parseLong()</code>.</li> |
| 435 | + <li>Integer.class - The string value is a valid argument to <code>Integer.parseInt()</code>.</li> |
| 436 | + <li>Short.class - The string value is a valid argument to <code>Short.parseShort()</code>.</li> |
| 437 | + <li>Byte.class - The string value is a valid argument to <code>Byte.parseByte()</code>.</li> |
| 438 | + <li>Character.class - The string value is either a UTF-8 encoding for a character (e.g. "\\u0124") or the first character from the String."</li> |
| 439 | + <li>Double.class - The string value is a valid argument to <code>Double.parseDouble()</code>.</li> |
| 440 | + <li>Float.class - The string value is a valid argument to <code>Float.parseFloat()</code>.</li> |
| 441 | + <li>BigInteger.class - The string value is a valid argument to <code>new BigInteger(s)</code>.</li> |
| 442 | + <li>BigDecimal.class - The string value is a valid argument to <code>new BigDecimal(s)</code>.</li> |
| 443 | + </ul> |
| 444 | + <p> |
440 | 445 | Additional types may be added to the automatic parsing system by calling <code>TypeHandler.register(Class<T> clazz, Converter<T> converter)</code>. |
441 | 446 | The <code>Class<T></code> can be any defined class. The converter is a function that takes a <code>String</code> argument and returns an instance of |
442 | 447 | the class. Any exception thrown by the constructor will be caught and reported as a <code>ParseException</code> |
@@ -580,11 +585,13 @@ public static void main(String[] args) { |
580 | 585 | <p> |
581 | 586 | The display of deprecated options may be changed through the use of the |
582 | 587 | <code>HelpFormatter.Builder.setShowDeprecated()</code> method. |
583 | | - <ul> |
584 | | - <li>Calling <code>HelpFormatter.Builder.setShowDeprecated(false)</code> will disable the "[Deprecated]" tag.</li> |
585 | | - <li>Calling <code>HelpFormatter.Builder.setShowDeprecated</code> with a <code>Function<Option, String></code> |
| 588 | + </p> |
| 589 | + <ul> |
| 590 | + <li>Calling <code>HelpFormatter.Builder.setShowDeprecated(false)</code> will disable the "[Deprecated]" tag.</li> |
| 591 | + <li>Calling <code>HelpFormatter.Builder.setShowDeprecated</code> with a <code>Function<Option, String></code> |
586 | 592 | will use the output of the function as the description for the option.</li> |
587 | | - </ul> |
| 593 | + </ul> |
| 594 | + <p> |
588 | 595 | As an example of the second case above, changing the implementation of <code>doSomething</code> to |
589 | 596 | <source> |
590 | 597 | void doSomething(Options options) { |
|
0 commit comments