diff options
Diffstat (limited to 'base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileShowCLI.java')
-rw-r--r-- | base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileShowCLI.java | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileShowCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileShowCLI.java index 37d1ed40d..1a4f8a81f 100644 --- a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileShowCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileShowCLI.java @@ -20,6 +20,7 @@ package com.netscape.cmstools.tps.profile; 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 ProfileShowCLI extends CLI { public ProfileShowCLI(ProfileCLI profileCLI) { super("show", "Show profile", profileCLI); this.profileCLI = profileCLI; + + createOptions(); } public void printHelp() { - formatter.printHelp(getFullName() + " <Profile ID>", options); + formatter.printHelp(getFullName() + " <Profile ID> [OPTIONS...]", options); } - public void execute(String[] args) throws Exception { - + public void createOptions() { Option option = new Option(null, "output", true, "Output file to store profile 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 ProfileShowCLI 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 Profile ID specified."); printHelp(); - System.exit(1); + System.exit(-1); } String profileID = args[0]; |