joptsimple.BarclayOptionParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of barclay Show documentation
Show all versions of barclay Show documentation
Development on Barclay command line parsing and documentation utilities
The newest version!
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.
*/
@Override
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);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy