summaryrefslogtreecommitdiffstats
path: root/base/java-tools/src/com/netscape/cmstools/profile/ProfileFindCLI.java
diff options
context:
space:
mode:
Diffstat (limited to 'base/java-tools/src/com/netscape/cmstools/profile/ProfileFindCLI.java')
-rw-r--r--base/java-tools/src/com/netscape/cmstools/profile/ProfileFindCLI.java27
1 files changed, 20 insertions, 7 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/profile/ProfileFindCLI.java b/base/java-tools/src/com/netscape/cmstools/profile/ProfileFindCLI.java
index bbadca6c3..9552fd70d 100644
--- a/base/java-tools/src/com/netscape/cmstools/profile/ProfileFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/profile/ProfileFindCLI.java
@@ -1,5 +1,6 @@
package com.netscape.cmstools.profile;
+import java.util.Arrays;
import java.util.Collection;
import org.apache.commons.cli.CommandLine;
@@ -17,14 +18,15 @@ public class ProfileFindCLI extends CLI {
public ProfileFindCLI(ProfileCLI profileCLI) {
super("find", "Find profiles", profileCLI);
this.profileCLI = profileCLI;
+
+ createOptions();
}
public void printHelp() {
- formatter.printHelp(getFullName() + " [FILTER] [OPTIONS...]", options);
+ formatter.printHelp(getFullName() + " [OPTIONS...]", options);
}
- public void execute(String[] args) throws Exception {
-
+ public void createOptions() {
Option option = new Option(null, "start", true, "Page start");
option.setArgName("start");
options.addOption(option);
@@ -32,6 +34,15 @@ public class ProfileFindCLI extends CLI {
option = new Option(null, "size", true, "Page size");
option.setArgName("size");
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;
@@ -41,13 +52,15 @@ public class ProfileFindCLI extends CLI {
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
printHelp();
- System.exit(1);
+ System.exit(-1);
}
- if (cmd.hasOption("help")) {
- // Display usage
+ String[] cmdArgs = cmd.getArgs();
+
+ if (cmdArgs.length != 0) {
+ System.err.println("Error: Too many arguments specified.");
printHelp();
- System.exit(0);
+ System.exit(-1);
}
String s = cmd.getOptionValue("start");