diff options
author | Endi S. Dewata <edewata@redhat.com> | 2013-08-06 02:29:50 -0400 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2013-08-23 23:17:21 -0400 |
commit | ccb8d7148fc4f50fa9d949edb4f47ad6742af2bc (patch) | |
tree | 376f44c0eaa0a39c4787fb8bf09aa9ddfd85eeac /base/java-tools/src/com/netscape/cmstools/profile/ProfileCLI.java | |
parent | 752166224154243f93fad5ea10dd4ebd87e1c369 (diff) | |
download | pki-ccb8d7148fc4f50fa9d949edb4f47ad6742af2bc.tar.gz pki-ccb8d7148fc4f50fa9d949edb4f47ad6742af2bc.tar.xz pki-ccb8d7148fc4f50fa9d949edb4f47ad6742af2bc.zip |
Refactored CLI framework.
Some common CLI methods and attributes have been refactored into the CLI base
class. A new SubsystemCLI class was added as the base for subsystem CLI
modules. The MainCLI was modified such that it will only perform authentication
if the subsystem is specified in the server URI. If no subsystem is specified
in the URI, the authentication will be done by the subsystem CLI module.
Ticket #701
Diffstat (limited to 'base/java-tools/src/com/netscape/cmstools/profile/ProfileCLI.java')
-rw-r--r-- | base/java-tools/src/com/netscape/cmstools/profile/ProfileCLI.java | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/profile/ProfileCLI.java b/base/java-tools/src/com/netscape/cmstools/profile/ProfileCLI.java index ba41a3da1..59f63c7e9 100644 --- a/base/java-tools/src/com/netscape/cmstools/profile/ProfileCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/profile/ProfileCLI.java @@ -12,8 +12,6 @@ import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; -import org.apache.commons.lang.StringUtils; - import com.netscape.certsrv.profile.ProfileAttribute; import com.netscape.certsrv.profile.ProfileClient; import com.netscape.certsrv.profile.ProfileData; @@ -24,12 +22,11 @@ import com.netscape.cmstools.cli.CLI; import com.netscape.cmstools.cli.MainCLI; public class ProfileCLI extends CLI { - public MainCLI parent; - public ProfileClient client; - public ProfileCLI(MainCLI parent) { - super("profile", "Profile management commands"); - this.parent = parent; + public ProfileClient profileClient; + + public ProfileCLI(CLI parent) { + super("profile", "Profile management commands", parent); addModule(new ProfileFindCLI(this)); addModule(new ProfileShowCLI(this)); @@ -40,30 +37,19 @@ public class ProfileCLI extends CLI { addModule(new ProfileDisableCLI(this)); } - public void printHelp() { - - System.out.println("Commands:"); - - int leftPadding = 1; - int rightPadding = 25; - - for (CLI module : modules.values()) { - String label = name + "-" + module.getName(); - - int padding = rightPadding - leftPadding - label.length(); - if (padding < 1) - padding = 1; - - System.out.print(StringUtils.repeat(" ", leftPadding)); - System.out.print(label); - System.out.print(StringUtils.repeat(" ", padding)); - System.out.println(module.getDescription()); + public String getFullName() { + if (parent instanceof MainCLI) { + // do not include MainCLI's name + return name; + } else { + return parent.getFullName() + "-" + name; } } public void execute(String[] args) throws Exception { - client = new ProfileClient(parent.client); + client = parent.getClient(); + profileClient = new ProfileClient(client); if (args.length == 0) { printHelp(); |