diff options
Diffstat (limited to 'base/java-tools/src/com/netscape/cmstools/user/UserFindCLI.java')
-rw-r--r-- | base/java-tools/src/com/netscape/cmstools/user/UserFindCLI.java | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserFindCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserFindCLI.java index 2dfa45bc4..64653105f 100644 --- a/base/java-tools/src/com/netscape/cmstools/user/UserFindCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/user/UserFindCLI.java @@ -18,6 +18,7 @@ package com.netscape.cmstools.user; +import java.util.Arrays; import java.util.Collection; import org.apache.commons.cli.CommandLine; @@ -38,14 +39,15 @@ public class UserFindCLI extends CLI { public UserFindCLI(UserCLI userCLI) { super("find", "Find users", userCLI); this.userCLI = userCLI; + + createOptions(); } public void printHelp() { formatter.printHelp(getFullName() + " [FILTER] [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); @@ -53,6 +55,15 @@ public class UserFindCLI 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; @@ -62,13 +73,7 @@ public class UserFindCLI 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(); |