@@ -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 ();
7777CommandLine 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
341337Options options = new Options();
0 commit comments