Skip to content

Commit 10b14af

Browse files
committed
Deprecated PosixParser, GnuParser and BasicParser in favor of DefaultParser
Updated the documentation accordingly git-svn-id: https://svn.apache.org/repos/asf/commons/proper/cli/trunk@955057 13f79535-47bb-0310-9956-ffa450edef68
1 parent 180a16d commit 10b14af

5 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/java/org/apache/commons/cli/BasicParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*
2424
* @author John Keyes (john at integralsource.com)
2525
* @version $Revision$, $Date$
26+
* @deprecated Use the {@link DefaultParser} instead
2627
*/
2728
public class BasicParser extends Parser
2829
{

src/java/org/apache/commons/cli/GnuParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
*
2727
* @author John Keyes (john at integralsource.com)
2828
* @version $Revision$, $Date$
29+
* @deprecated Use the {@link DefaultParser} instead
2930
*/
3031
public class GnuParser extends Parser
3132
{

src/java/org/apache/commons/cli/Parser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
*
3131
* @author John Keyes (john at integralsource.com)
3232
* @version $Revision$, $Date$
33+
* @deprecated The two-pass parsing with the flatten method is not enough flexible to handle complex cases
3334
*/
3435
public abstract class Parser implements CommandLineParser
3536
{

src/java/org/apache/commons/cli/PosixParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
*
2929
* @author John Keyes (john at integralsource.com)
3030
* @version $Revision$, $Date$
31+
* @deprecated Use the {@link DefaultParser} instead
3132
*/
3233
public class PosixParser extends Parser
3334
{

src/site/xdoc/usage.xml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ options.addOption("t", false, "display current time");</source>
6969
<subsection name="Parsing the command line arguments">
7070
<p>
7171
The <code>parse</code> methods of <code>CommandLineParser</code> are used
72-
to parse the command line arguments. The <code>PosixPaser</code> is
73-
great when you need to handle options that are one character long,
74-
like the <code>t</code> option in this example.
72+
to parse the command line arguments. There may be several implementations
73+
of the <code>CommandLineParser</code> interface, the recommended one is the
74+
<code>DefaultParser</code>.
7575
</p>
76-
<source>CommandLineParser parser = new PosixParser();
76+
<source>CommandLineParser parser = new DefaultParser();
7777
CommandLine cmd = parser.parse( options, args);</source>
7878
<p>
7979
Now we need to check if the <code>t</code> option is present. To do
@@ -241,15 +241,13 @@ options.addOption( property );</source>
241241
</subsection>
242242
<subsection name="Create the Parser">
243243
<p>
244-
We now need to create a <code>Parser</code>. This will parse the command
244+
We now need to create a <code>CommandLineParser</code>. This will parse the command
245245
line arguments, using the rules specified by the <code>Options</code> and
246246
return an instance of <a href="api-1.2/org/apache/commons/cli/CommandLine.html">CommandLine</a>.
247-
This time we will use a <a href="api-1.2/org/apache/commons/cli/GnuParser.html">GnuParser</a>
248-
which is able to handle options that are more than one character long.
249247
</p>
250248
<source>public static void main( String[] args ) {
251249
// create the parser
252-
CommandLineParser parser = new GnuParser();
250+
CommandLineParser parser = new DefaultParser();
253251
try {
254252
// parse the command line arguments
255253
CommandLine line = parser.parse( options, args );
@@ -310,10 +308,8 @@ formatter.printHelp( "ant", options );</source>
310308
<section name="ls Example">
311309
<p>
312310
One of the most widely used command line applications in the *nix world
313-
is <code>ls</code>. To parse a command line for an application like this
314-
we will use the <a href="api-1.2/org/apache/commons/cli/PosixParser.html">PosixParser</a>.
315-
Due to the large number of options required for <code>ls</code> this
316-
example will only cover a small proportion of the options. The following
311+
is <code>ls</code>. Due to the large number of options required for <code>ls</code>
312+
this example will only cover a small proportion of the options. The following
317313
is a section of the help output.
318314
</p>
319315
<source>Usage: ls [OPTION]... [FILE]...
@@ -335,7 +331,7 @@ Sort entries alphabetically if none of -cftuSUX nor --sort.
335331
<a href="api-1.2/org/apache/commons/cli/Options.html">Options</a> for this example.
336332
</p>
337333
<source>// create the command line parser
338-
CommandLineParser parser = new PosixParser();
334+
CommandLineParser parser = new DefaultParser();
339335

340336
// create the Options
341337
Options options = new Options();

0 commit comments

Comments
 (0)