diff options
Diffstat (limited to 'base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileAddCLI.java')
-rw-r--r-- | base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileAddCLI.java | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileAddCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileAddCLI.java index 70e0e8c7f..11fbb21c4 100644 --- a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileAddCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileAddCLI.java @@ -41,26 +41,29 @@ public class ProfileAddCLI extends CLI { public ProfileAddCLI(ProfileCLI profileCLI) { super("add", "Add profile", profileCLI); this.profileCLI = profileCLI; + + createOptions(); } public void printHelp() { - formatter.printHelp(getFullName() + " [OPTIONS...]", options); + formatter.printHelp(getFullName() + " --input <file> [OPTIONS...]", options); } - public void execute(String[] args) throws Exception { + public void createOptions() { + Option option = new Option(null, "input", true, "Input file containing profile properties."); + option.setArgName("file"); + option.setRequired(true); + options.addOption(option); + } - // Check for "--help" prior to parsing due to required 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); } - Option option = new Option(null, "input", true, "Input file containing profile properties."); - option.setArgName("file"); - option.setRequired(true); - options.addOption(option); - CommandLine cmd = null; try { @@ -69,14 +72,15 @@ public class ProfileAddCLI extends CLI { } catch (Exception e) { System.err.println("Error: " + e.getMessage()); printHelp(); - System.exit(1); + System.exit(-1); } String[] cmdArgs = cmd.getArgs(); if (cmdArgs.length != 0) { + System.err.println("Error: Too many arguments specified."); printHelp(); - System.exit(1); + System.exit(-1); } String input = cmd.getOptionValue("input"); |