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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]