Rewrite AppOptions to instead use non-static attributes
This commit is contained in:
parent
a7882ab201
commit
653e5295de
2 changed files with 7 additions and 13 deletions
|
@ -22,14 +22,7 @@ import org.apache.commons.cli.Option;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
|
|
||||||
final class AppOptions {
|
final class AppOptions {
|
||||||
public final static Option help = Option.builder().argName("h").longOpt("help").desc("Shows this help " + "message and exits").build();
|
public final Option help = Option.builder().argName("h").longOpt("help").desc("Shows this help " + "message and exits").build();
|
||||||
public final static Option version = Option.builder().argName("v").longOpt("version").desc("Shows version information and exits").build();
|
public final Option version = Option.builder().argName("v").longOpt("version").desc("Shows version information and exits").build();
|
||||||
private final static Options options = new Options().addOption(help).addOption(version);
|
public final Options options = new Options().addOption(help).addOption(version);
|
||||||
|
|
||||||
// Disable Instance Creation
|
|
||||||
private AppOptions() {}
|
|
||||||
|
|
||||||
public static Options getOptions() {
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,14 +55,15 @@ public final class Main {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(final String[] args) {
|
public static void main(final String[] args) {
|
||||||
|
final var appOptions = new AppOptions();
|
||||||
try {
|
try {
|
||||||
final var parsedArguments = DefaultParser.builder().setStripLeadingAndTrailingQuotes(true).build().parse(AppOptions.getOptions(), args);
|
final var parsedArguments = DefaultParser.builder().setStripLeadingAndTrailingQuotes(true).build().parse(appOptions.options, args);
|
||||||
|
|
||||||
final var userData = parsedArguments.getArgs();
|
final var userData = parsedArguments.getArgs();
|
||||||
|
|
||||||
if (parsedArguments.hasOption(AppOptions.help)) {
|
if (parsedArguments.hasOption(appOptions.help)) {
|
||||||
printHelpInformation();
|
printHelpInformation();
|
||||||
} else if (parsedArguments.hasOption(AppOptions.version)) {
|
} else if (parsedArguments.hasOption(appOptions.version)) {
|
||||||
printVersionInformation();
|
printVersionInformation();
|
||||||
} else if (userData.length == 0) {
|
} else if (userData.length == 0) {
|
||||||
switch (applicationOutputLanguage) {
|
switch (applicationOutputLanguage) {
|
||||||
|
|
Loading…
Reference in a new issue