Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Un-hide this method that may be needed in override.
  • Loading branch information
cstamas committed Jun 9, 2025
commit 3f7d699c7414bd41f4439654efda558e985daa7d
14 changes: 12 additions & 2 deletions src/main/java/org/apache/commons/cli/DefaultParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ private void handleToken(final String token) throws ParseException {
if (token != null) {
currentToken = token;
if (skipParsing) {
cmd.addArg(token);
addArg(token);
} else if ("--".equals(token)) {
skipParsing = true;
} else if (currentOption != null && currentOption.acceptsArg() && isArgument(token)) {
Expand Down Expand Up @@ -588,12 +588,22 @@ protected void handleUnknownToken(final String token) throws ParseException {
if (token.startsWith("-") && token.length() > 1 && !stopAtNonOption) {
throw new UnrecognizedOptionException("Unrecognized option: " + token, token);
}
cmd.addArg(token);
addArg(token);
if (stopAtNonOption) {
skipParsing = true;
}
}

/**
* Adds token to command line {@link CommandLine#addArg(String)}.
*
* @param token the unrecognized option/argument.
* @since 1.10.0
*/
protected void addArg(final String token) {
cmd.addArg(token);
}

/**
* Tests if the token is a valid argument.
*
Expand Down