Class CLIDriver

  • Direct Known Subclasses:
    SASCLIDriver, SASServerSideCLiDriver

    public class CLIDriver
    extends Object
    A driver program that does introspection on a set of CLICommands

    Created by Jeff Gaynor
    on 5/17/13 at 3:01 PM

    • Constructor Detail

      • CLIDriver

        public CLIDriver()
      • CLIDriver

        public CLIDriver​(Commands... cci)
      • CLIDriver

        public CLIDriver​(IOInterface ioInterface)
    • Method Detail

      • getLineCommentStart

        public String getLineCommentStart()
      • setLineCommentStart

        public void setLineCommentStart​(String lineCommentStart)
      • hasComments

        public boolean hasComments()
        If a comment delimiter has been set for this component. If so, then lines that start with this are ignored.
        Returns:
      • getCommandHistory

        public List<String> getCommandHistory()
      • setCommandHistory

        public void setCommandHistory​(List<String> commandHistory)
      • getEnv

        public Map getEnv()
      • setEnv

        public void setEnv​(Map env)
      • hasEnv

        public boolean hasEnv()
      • addCommands

        public void addCommands​(Commands... cci)
      • getCLICommands

        public Commands[] getCLICommands()
      • setCLICommands

        protected void setCLICommands​(Commands[] commands)
      • noPrompt

        protected boolean noPrompt()
      • printHelp

        protected void printHelp()
      • doRepeatCommand

        protected String doRepeatCommand​(String cmdLine)
      • doHistory

        protected String doHistory​(String cmdLine)
      • setComponentManager

        public void setComponentManager​(ComponentManager componentManager)
      • start

        public void start()
        Actual method that starts up this driver and sets out prompts etc. for the user to use interactively.
        Throws:
        Exception
      • NEWstart

        protected void NEWstart()
      • isTraceOn

        public boolean isTraceOn()
      • setTraceOn

        public void setTraceOn​(boolean traceOn)
      • execute

        public int execute​(String cmdLine)
      • execute

        public int execute​(InputLine cliAV)
        Returns a logical true if one of the command lines executes the line successfully. This will also throw a shutdown exception if the user asks it to... Otherwise, it returns false;
        Parameters:
        cliAV -
        Returns:
      • getHelpUtil

        public HelpUtil getHelpUtil()
      • setHelpUtil

        public void setHelpUtil​(HelpUtil helpUtil)
      • doHelp

        protected void doHelp​(InputLine inputLine)
      • printHelpTopics

        protected void printHelpTopics​(InputLine inputLine)
      • listCLIMethods

        protected void listCLIMethods​(InputLine inputLine)
      • quit

        public void quit​(InputLine inputLine)
      • shutdown

        protected void shutdown()
      • say

        protected void say​(String x)
        For use with informational messages.
        Parameters:
        x -
      • sayv

        protected void sayv​(String x)
        Conditional output if in verbose mode only.
        Parameters:
        x -
      • setIOInterface

        public void setIOInterface​(IOInterface ioInterface)
        This also sets any components you added.
        Parameters:
        ioInterface -
      • processRunLine

        protected void processRunLine()
        Process a line to run. At invocation you may use something like
             cli RUN_COMMAND_FLAG A B C
         
        and what happens is that everything after the flag is fed tot he processor and executed as a single command, as if you'd type in
             A B C
         
        This lets you do things like
             cli -run use clients
         
        to start a component right away.
      • batchFileHelp

        protected void batchFileHelp()
      • main

        public static void main​(String[] args)
      • hasOutputFile

        public boolean hasOutputFile()
      • getOutputFile

        public String getOutputFile()
      • setOutputFile

        public void setOutputFile​(String outputFile)
      • isVerbose

        public boolean isVerbose()
      • setVerbose

        public void setVerbose​(boolean verbose)
      • isOutputOn

        public boolean isOutputOn()
      • setOutputOn

        public void setOutputOn​(boolean outputOn)
      • isRunLineMode

        public boolean isRunLineMode()
      • setRunLineMode

        public void setRunLineMode​(boolean runLineMode)
      • getRunLine

        public String getRunLine()
      • setRunLine

        public void setRunLine​(String runLine)
      • bootstrap

        public InputLine bootstrap​(String[] args)
        This method is charged with interpreting the command line arguments and setting up the state for this CLI driver. State includes These properties are injected into any component when set. However, this is a one-time undertaking and the Commands are not altered after that. So either create a CLIDriver, set your components and call this to inject the state, or create this, call this method and then add your components. You call
        Parameters:
        args -
        Returns:
        The InputLine after all recognized flags have been processed. This means they are stripped.
      • hasInputFile

        public boolean hasInputFile()
      • setHasInputFile

        public void setHasInputFile​(boolean hasInputFile)
      • hasCLIDriver

        public static boolean hasCLIDriver()
      • setCLIDriver

        public static void setCLIDriver​(CLIDriver driver)
      • getCLIDriver

        public static CLIDriver getCLIDriver()
      • readEnv

        protected void readEnv​(String path,
                               boolean verbose)
      • getCurrentEnvFile

        public String getCurrentEnvFile()
      • setCurrentEnvFile

        public void setCurrentEnvFile​(String currentEnvFile)
      • isTrue

        public Boolean isTrue​(String raw)
        This checks that the string is one of the allowed trues or false. Anything else returns a null.
        Parameters:
        raw -
        Returns: