Class AbstractCommandsImpl

    • Constructor Detail

      • AbstractCommandsImpl

        public AbstractCommandsImpl​(CLIDriver driver)
    • Method Detail

      • showHelp

        protected boolean showHelp​(InputLine inputLine)
        returns "true if the command has the flag --help in it. This is a cue from the user to show the help for a given function. So it the function is called "X" and its help is in the function "showXHelp" then a value of true from this should simply invoke "showXHelp" and return.
        Parameters:
        inputLine -
        Returns:
      • getPropertyHelp

        protected String getPropertyHelp​(String propertyName,
                                         String prompt,
                                         String defaultValue)
                                  throws IOException

        One of the most important help methods, but only used in subclasses.

        Use this to get a property and also allow for getting help. This is just getInput(String, String) but with the optional lookup of help for the propertyName if the user enters --help or /help. It will then re-prompt for the input.

        Parameters:
        propertyName -
        prompt -
        defaultValue -
        Returns:
        Throws:
        IOException
      • getInput

        protected String getInput​(String prompt,
                                  String defaultValue)
                           throws IOException
        Creates the input prompt and shows the supplied default value. This returns the default if the default value is chosen and the input value otherwise. If supplied the default value is a null, then this is shown too.
        Parameters:
        prompt -
        defaultValue -
        Returns:
        Throws:
        IOException
      • readline

        protected String readline()
      • getDriver

        public CLIDriver getDriver()
        Description copied from interface: Commands
        Back reference to the driver that manages this instance.
        Specified by:
        getDriver in interface Commands
        Returns:
      • isShowHeader

        public boolean isShowHeader()
        Show the header, if any, at startup?
        Returns:
      • setShowHeader

        public void setShowHeader​(boolean showHeader)
      • isShowLogo

        public boolean isShowLogo()
        Show the logo, if any, at startup?
        Returns:
      • setShowLogo

        public void setShowLogo​(boolean showLogo)
      • getLogoName

        public String getLogoName()
      • setLogoName

        public void setLogoName​(String logoName)
      • about

        public abstract void about​(boolean showBanner,
                                   boolean showHeader)
        This will show the boot up logos, header (additional info) etc. if any
      • initialize

        public abstract void initialize()
                                 throws Throwable
        Finish initializing this implementation.
        Throws:
        Throwable
      • load

        public abstract void load​(InputLine inputLine)
                           throws Throwable
        Load resources before showing logos etc. This is typically called on your behalf in bootstrap(InputLine) amd should load resources needed. Note that an exception in this does not stop booting. This allows you to start a system with a missing configuration file (for instnace) and prompt for it.

        See initialize() which is called after this and is charged with actually starting
        Parameters:
        inputLine -
        Throws:
        Throwable
      • hasLogger

        protected boolean hasLogger()
      • isDebugOn

        public boolean isDebugOn()
        Description copied from interface: Logable
        Query if debugging is enabled for this logger.
        Specified by:
        isDebugOn in interface Logable
        Returns:
      • setDebugOn

        public void setDebugOn​(boolean setOn)
        Description copied from interface: Logable
        Enable/disable debugging for this logger
        Specified by:
        setDebugOn in interface Logable
      • debug

        public void debug​(String x)
        Description copied from interface: Logable
        Write a debug message to the log.
        Specified by:
        debug in interface Logable
      • info

        public void info​(String x)
        Description copied from interface: Logable
        Write an informational message to the log
        Specified by:
        info in interface Logable
      • warn

        public void warn​(String x)
        Description copied from interface: Logable
        Write a warning to the log. This indicates a severe, but non-fatal condition exists.
        Specified by:
        warn in interface Logable
      • error

        public void error​(String x)
        Description copied from interface: Logable
        Write an error message to the log. Typically this is invoked as the last command before throwing an exception.
        Specified by:
        error in interface Logable
      • isOk

        protected boolean isOk​(String x)
        Used when reading lines to check is the user typed a "y" for yes.
        Parameters:
        x -
        Returns:
      • getHelpUtil

        public HelpUtil getHelpUtil()
      • printReadEnvHelp

        protected void printReadEnvHelp()
      • printSetEnvHelp

        protected void printSetEnvHelp()
      • printGetEnvHelp

        protected void printGetEnvHelp()
      • printSaveEnvHelp

        protected void printSaveEnvHelp()
      • printEnvHelp

        protected void printEnvHelp()
      • clearEnvHelp

        protected void clearEnvHelp()
      • gracefulExit

        protected boolean gracefulExit​(boolean exitNow,
                                       String msg)
        Exit gracefully. That is to say, if the exitNow flag is true, do a system shutdown in batch mode and otherwise, do nothing. If the flag is true and the mode is interactive, then print the message and return true, prompting the system to return;
        Parameters:
        exitNow -
        msg -
        Returns:
      • say

        protected void say​(String x)
        Prints with the default indent and a linefeed.
        Parameters:
        x -
      • say

        protected void say()
        Linefeed.
      • sayv

        protected void sayv​(String x)
        Use this for verbose mode.
        Parameters:
        x -
      • sayi

        protected void sayi​(String x)
        prints with the current indent and a linefeed.
        Parameters:
        x -
      • indentWidth

        public int indentWidth()