summaryrefslogtreecommitdiffstats
path: root/base/java-tools/src/com/netscape/cmstools/cert/CertHoldCLI.java
diff options
context:
space:
mode:
Diffstat (limited to 'base/java-tools/src/com/netscape/cmstools/cert/CertHoldCLI.java')
-rw-r--r--base/java-tools/src/com/netscape/cmstools/cert/CertHoldCLI.java28
1 files changed, 17 insertions, 11 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/cert/CertHoldCLI.java b/base/java-tools/src/com/netscape/cmstools/cert/CertHoldCLI.java
index eb4f619a4..a4b184871 100644
--- a/base/java-tools/src/com/netscape/cmstools/cert/CertHoldCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cert/CertHoldCLI.java
@@ -20,6 +20,7 @@ package com.netscape.cmstools.cert;
import java.io.BufferedReader;
import java.io.InputStreamReader;
+import java.util.Arrays;
import netscape.security.x509.RevocationReason;
@@ -44,19 +45,29 @@ public class CertHoldCLI extends CLI {
public CertHoldCLI(CertCLI certCLI) {
super("hold", "Place certificate on-hold", certCLI);
this.certCLI = certCLI;
+
+ createOptions();
}
public void printHelp() {
formatter.printHelp(getFullName() + " <Serial Number> [OPTIONS...]", options);
}
- public void execute(String[] args) throws Exception {
-
+ public void createOptions() {
Option option = new Option(null, "comments", true, "Comments");
option.setArgName("comments");
options.addOption(option);
options.addOption(null, "force", false, "Force");
+ }
+
+ 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;
@@ -66,20 +77,15 @@ public class CertHoldCLI 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: Missing Serial Number.");
printHelp();
- System.exit(1);
+ System.exit(-1);
}
CertId certID = new CertId(cmdArgs[0]);
@@ -98,7 +104,7 @@ public class CertHoldCLI extends CLI {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String line = reader.readLine();
if (!line.equalsIgnoreCase("Y")) {
- System.exit(1);
+ System.exit(-1);
}
}