File tree Expand file tree Collapse file tree
src/java/org/apache/commons/cli2/commandline Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,26 +54,32 @@ public class Parser {
5454 * command line tokens.
5555 */
5656 public CommandLine parse (final String [] arguments ) throws OptionException {
57-
57+
58+ // build a mutable list for the arguments
5859 final List argumentList = new LinkedList (Arrays .asList (arguments ));
5960 final WriteableCommandLine commandLine =
6061 new WriteableCommandLineImpl (group , new ArrayList ());
6162
6263 // pick up any defaults from the model
6364 group .defaults (commandLine );
64-
65+
66+ // process the options as far as possible
6567 final ListIterator iterator = argumentList .listIterator ();
6668 while (group .canProcess (commandLine , iterator )) {
6769 group .process (commandLine , iterator );
6870 }
69-
71+
72+ // if there are more arguments we have a problem
7073 if (iterator .hasNext ()) {
7174 final String arg = (String )iterator .next ();
7275 throw new OptionException (group , "cli.error.unexpected" , arg );
7376 }
74-
75- group .validate (commandLine );
76-
77+
78+ // no need to validate if the help option is present
79+ if (!commandLine .hasOption (helpOption ) && !commandLine .hasOption (helpTrigger )) {
80+ group .validate (commandLine );
81+ }
82+
7783 return commandLine ;
7884 }
7985
You can’t perform that action at this time.
0 commit comments