-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package joptsimple; | ||
|
||
import joptsimple.util.KeyValuePair; | ||
|
||
/** | ||
* Custom subclass of the jopt parser for Barclay. Overrides short argument handling | ||
* so that short arg clustering is disabled. | ||
*/ | ||
public class BarclayOptionParser extends OptionParser { | ||
public BarclayOptionParser(final boolean allowAbbreviations) { | ||
super(allowAbbreviations); | ||
} | ||
|
||
/** | ||
* Only delegate short arg handling to the base class if we're guaranteed that the option will be | ||
* recognized using the full argument string. Otherwise the base class implementation will fall back | ||
* to clustered short name recognition, which we want to disable to avoid the confusing error message | ||
* generated. | ||
*/ | ||
void handleShortOptionToken( String candidate, ArgumentList arguments, OptionSet detected ) { | ||
KeyValuePair optionAndArgument = KeyValuePair.valueOf( candidate.substring( 1 ) ); | ||
|
||
if ( isRecognized( optionAndArgument.key ) ) { | ||
super.handleShortOptionToken(candidate, arguments, detected ); | ||
} | ||
else { | ||
throw new UnrecognizedOptionException(candidate); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters