commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roxspr...@apache.org
Subject svn commit: r190810 - /jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java
Date Wed, 15 Jun 2005 21:20:10 GMT
Author: roxspring
Date: Wed Jun 15 14:20:09 2005
New Revision: 190810

URL: http://svn.apache.org/viewcvs?rev=190810&view=rev
Log:
Parser no longer validates the CommandLine if the help option is found

Modified:
    jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java

Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java?rev=190810&r1=190809&r2=190810&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java
Wed Jun 15 14:20:09 2005
@@ -54,26 +54,32 @@
      *             command line tokens.
      */
     public CommandLine parse(final String[] arguments) throws OptionException {
-
+        
+        // build a mutable list for the arguments
         final List argumentList = new LinkedList(Arrays.asList(arguments));
         final WriteableCommandLine commandLine =
             new WriteableCommandLineImpl(group, new ArrayList());
         
         // pick up any defaults from the model
         group.defaults(commandLine);
-
+        
+        // process the options as far as possible
         final ListIterator iterator = argumentList.listIterator();
         while (group.canProcess(commandLine, iterator)) {
             group.process(commandLine, iterator);
         }
-
+        
+        // if there are more arguments we have a problem
         if (iterator.hasNext()) {
             final String arg = (String)iterator.next();
             throw new OptionException(group, "cli.error.unexpected", arg);
         }
-
-        group.validate(commandLine);
-
+        
+        // no need to validate if the help option is present
+        if (!commandLine.hasOption(helpOption) && !commandLine.hasOption(helpTrigger))
{
+            group.validate(commandLine);
+        }
+        
         return commandLine;
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message