Class SubCommand


  • public class SubCommand
    extends Object
    This class contains definition of sub command.
    • Constructor Detail

      • SubCommand

        public SubCommand​(IDefinition definition,
                          ResourceBundle rb,
                          String name,
                          List mandatoryOptions,
                          List optionalOptions,
                          List optionAliases,
                          String implClassName,
                          boolean webSupport,
                          String deprecationWarning)
                   throws CLIException
        Creates a sub command object.
        Parameters:
        definition - Definition class.
        rb - Resource Bundle.
        name - Name of the Sub Command.
        mandatoryOptions - Formated list of mandatory argument/options.
        optionalOptions - Formated list of optional argument/options.
        optionAliases - Formated list of argument/options aliases.
        implClassName - Implementation class name.
        webSupport - true if this command is supported on the web browser.
        deprecationWarning - if set to a non zero length string (default is "") then print this warning.
        Throws:
        CLIException - if this object cannot be constructed.
    • Method Detail

      • isReservedShortOption

        public static boolean isReservedShortOption​(String name)
        Returns true if an argument/option is reserved.
        Parameters:
        name - Short name of argument/option.
        Returns:
        true if an argument/option is reserved.
      • isReservedLongOption

        public static boolean isReservedLongOption​(String name)
        Returns true if an argument/option is reserved.
        Parameters:
        name - Full name of argument/option.
        Returns:
        true if an argument/option is reserved.
      • getReservedShortOptionName

        public static String getReservedShortOptionName​(String longName)
        Returns short reserved argument/option name given its long name.
        Parameters:
        longName - Long name of reserved argument/option.
        Returns:
        short reserved argument/option name given its long name. Returns null if short name is not found.
      • getReservedLongOptionName

        public static String getReservedLongOptionName​(String shortName)
        Returns long reserved argument/option name given its short name.
        Parameters:
        shortName - Short name of reserved argument/option.
        Returns:
        long reserved argument/option name given its short name. Returns null if long name is not found.
      • getName

        public String getName()
        Returns name of the sub command.
        Returns:
        name of the sub command.
      • getDescription

        public String getDescription()
        Returns description of the sub command.
        Returns:
        description of the sub command.
      • getOptionalOptions

        public List getOptionalOptions()
        Returns list of optional argument/options.
        Returns:
        list of optional argument/options.
      • getMandatoryOptions

        public List getMandatoryOptions()
        Returns list of mandatory argument/options.
        Returns:
        list of mandatory argument/options.
      • getOptionAliases

        public List getOptionAliases​(String name)
        Returns option aliases.
        Parameters:
        name - Full name of argument/option.
        Returns:
        get option aliases. Returns null of there are no aliases.
      • getOptionAliasesGroup

        public Set getOptionAliasesGroup​(String fullName)
        Returns option aliases group.
        Parameters:
        fullName - Full name of argument/option.
        Returns:
        option aliases group.
      • isOptionAlias

        public boolean isOptionAlias​(String name)
        Returns true if option is an alias.
        Parameters:
        name - Full name of argument/option.
        Returns:
        true if option is an alias.
      • validateOptions

        public boolean validateOptions​(Map options,
                                       SSOToken ssoToken)
        Returns true if the given options are valid in the context of this sub command.
        Parameters:
        options - Map of argument/option full name to its values (List).
        ssoToken - Single Sign On token of the user.
        Returns:
        true if the given options are valid.
      • getLongOptionName

        public String getLongOptionName​(String name)
        Returns long argument/option name given its short name.
        Parameters:
        name - short name of argument/option.
        Returns:
        long argument/option name given its short name. Returns null if short name is not found.
      • getShortOptionName

        public String getShortOptionName​(String name)
        Returns short argument/option name given its long name.
        Parameters:
        name - Long name of argument/option.
        Returns:
        short argument/option name given its long name. Returns null if short name is not found.
      • isSupportedOption

        public boolean isSupportedOption​(String name)
        Returns if the option is supported.
        Parameters:
        name - Name of the argument/option.
        Returns:
        if the option is supported.
      • getOptionDescription

        public String getOptionDescription​(String name)
        Returns the description of an argument/option.
        Parameters:
        name - Name of the argument/option.
        Returns:
        the description of an argument/option.
      • getOptionDescription

        public String getOptionDescription​(String name,
                                           boolean isWeb)
        Returns the description of an argument/option.
        Parameters:
        name - Name of the argument/option.
        isWeb - true if CLI is accessed via browser.
        Returns:
        the description of an argument/option.
      • getResourceBundle

        public ResourceBundle getResourceBundle()
        Returns resource bundle of the sub command.
        Returns:
        resource bundle of the sub command.
      • isUnaryOption

        public boolean isUnaryOption​(String cmdName)
        Returns true if option is unary.
        Returns:
        true if option is unary.
      • isBinaryOption

        public boolean isBinaryOption​(String cmdName)
        Returns true if option is binary.
        Returns:
        true if option is binary.
      • webEnabled

        public boolean webEnabled()
        Returns true if this command is supported on web browser.
        Returns:
        true if this command is supported on web browser.
      • getDeprecationWarning

        public String getDeprecationWarning()
        Returns:
        any deprecation warning (by default this is set to the empty string).
      • textareaUI

        public boolean textareaUI​(String opt)
        Returns true if option is to be displayed as text area in web based CLI.
        Parameters:
        opt - Name of option.
        Returns:
        true if option is to be displayed as text area.
      • checkboxUI

        public boolean checkboxUI​(String opt)
        Returns true if option is to be displayed as checkbox in web based CLI.
        Parameters:
        opt - Name of option.
        Returns:
        true if option is to be displayed as checkbox.