summaryrefslogtreecommitdiffstats
path: root/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestShowCLI.java
diff options
context:
space:
mode:
Diffstat (limited to 'base/java-tools/src/com/netscape/cmstools/selftests/SelfTestShowCLI.java')
-rw-r--r--base/java-tools/src/com/netscape/cmstools/selftests/SelfTestShowCLI.java28
1 files changed, 17 insertions, 11 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestShowCLI.java b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestShowCLI.java
index f579c1f67..56ff88954 100644
--- a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestShowCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestShowCLI.java
@@ -20,6 +20,7 @@ package com.netscape.cmstools.selftests;
import java.io.FileWriter;
import java.io.PrintWriter;
+import java.util.Arrays;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
@@ -38,17 +39,27 @@ public class SelfTestShowCLI extends CLI {
public SelfTestShowCLI(SelfTestCLI selfTestCLI) {
super("show", "Show selftest", selfTestCLI);
this.selfTestCLI = selfTestCLI;
+
+ createOptions();
}
public void printHelp() {
- formatter.printHelp(getFullName() + " <SelfTest ID>", options);
+ formatter.printHelp(getFullName() + " <SelfTest ID> [OPTIONS...]", options);
}
- public void execute(String[] args) throws Exception {
-
+ public void createOptions() {
Option option = new Option(null, "output", true, "Output file to store selfTest properties.");
option.setArgName("file");
options.addOption(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);
+ }
CommandLine cmd = null;
@@ -58,20 +69,15 @@ public class SelfTestShowCLI extends CLI {
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
printHelp();
- System.exit(1);
- }
-
- if (cmd.hasOption("help")) {
- // Display usage
- printHelp();
- System.exit(0);
+ System.exit(-1);
}
String[] cmdArgs = cmd.getArgs();
if (cmdArgs.length != 1) {
+ System.err.println("Error: No SelfTest ID specified.");
printHelp();
- System.exit(1);
+ System.exit(-1);
}
String selfTestID = args[0];