summaryrefslogtreecommitdiffstats
path: root/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorAddCLI.java
diff options
context:
space:
mode:
Diffstat (limited to 'base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorAddCLI.java')
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorAddCLI.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorAddCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorAddCLI.java
index 43a58c85c..524750947 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorAddCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorAddCLI.java
@@ -41,26 +41,29 @@ public class AuthenticatorAddCLI extends CLI {
public AuthenticatorAddCLI(AuthenticatorCLI authenticatorCLI) {
super("add", "Add authenticator", authenticatorCLI);
this.authenticatorCLI = authenticatorCLI;
+
+ createOptions();
}
public void printHelp() {
- formatter.printHelp(getFullName() + " [OPTIONS...]", options);
+ formatter.printHelp(getFullName() + " --input <file> [OPTIONS...]", options);
}
- public void execute(String[] args) throws Exception {
+ public void createOptions() {
+ Option option = new Option(null, "input", true, "Input file containing authenticator properties.");
+ option.setArgName("file");
+ option.setRequired(true);
+ options.addOption(option);
+ }
- // Check for "--help" prior to parsing due to required option
+ public void execute(String[] args) throws Exception {
+ // Always check for "--help" prior to parsing
if (Arrays.asList(args).contains("--help")) {
// Display usage
printHelp();
System.exit(0);
}
- Option option = new Option(null, "input", true, "Input file containing authenticator properties.");
- option.setArgName("file");
- option.setRequired(true);
- options.addOption(option);
-
CommandLine cmd = null;
try {
@@ -69,14 +72,15 @@ public class AuthenticatorAddCLI extends CLI {
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
printHelp();
- System.exit(1);
+ System.exit(-1);
}
String[] cmdArgs = cmd.getArgs();
if (cmdArgs.length != 0) {
+ System.err.println("Error: Too many arguments specified.");
printHelp();
- System.exit(1);
+ System.exit(-1);
}
String input = cmd.getOptionValue("input");