Class ConsoleCommand

    • Field Detail

      • LOGGER

        protected final org.slf4j.Logger LOGGER
    • Constructor Detail

      • ConsoleCommand

        public ConsoleCommand​(ConsoleIO consoleIO)
        Constructor
        Parameters:
        consoleIO -
      • ConsoleCommand

        public ConsoleCommand​(ConsoleIO consoleIO,
                              ConsoleState state)
        Constructor
        Parameters:
        consoleIO -
        state -
      • ConsoleCommand

        public ConsoleCommand​(ConsoleIO consoleIO,
                              ConsoleState state,
                              Map<String,​ConsoleSetting> settings)
        Constructor
        Parameters:
        consoleIO - console IO
        state - console state
        settings - console settings
    • Method Detail

      • getConsoleIO

        public ConsoleIO getConsoleIO()
        Get console IO
        Returns:
        console IO
      • getConsoleState

        public ConsoleState getConsoleState()
        Get console state
        Returns:
        console state
      • getConsoleSettings

        public Map<String,​ConsoleSetting> getConsoleSettings()
        Get console settings map
        Returns:
        map of console settings
      • getHelpShort

        public String getHelpShort()
        Get short description, small enough to fit on one console row
        Specified by:
        getHelpShort in interface Help
        Returns:
        help string
      • getHelpLong

        public String getHelpLong()
        Get long description
        Specified by:
        getHelpLong in interface Help
        Returns:
        string, can be multiple lines
      • usesSettings

        public String[] usesSettings()
        Description copied from interface: Command
        Return the names of the settings used.
        Specified by:
        usesSettings in interface Command
        Returns:
        string array of settings
      • execute

        public void execute​(String... parameters)
                     throws IOException
        Description copied from interface: Command
        Execute the given parameters.
        Specified by:
        execute in interface Command
        Parameters:
        parameters - parameters typed by user
        Throws:
        IOException - if a problem occurs reading or writing
      • write

        protected void write​(String str)
        Write a string to the console
        Parameters:
        str - text
      • writeln

        protected void writeln​(String str)
        Write a string + newline to the console
        Parameters:
        str - text
      • writeInfo

        protected void writeInfo​(String str)
        Write a string + newline to the console and to the log at level INFO
        Parameters:
        str - text
      • writeError

        protected void writeError​(String str)
        Write a string + newline to the console and to the log as an error
        Parameters:
        str - text
      • writeError

        protected void writeError​(String str,
                                  Exception e)
        Write a string + message of exception + newline to the console and to the log as an error
        Parameters:
        str - text
        e - exception
      • writeUnopenedError

        protected void writeUnopenedError()
        Write repository not opened error
      • askProceed

        protected boolean askProceed​(String str,
                                     boolean defVal)
        Ask user to proceed
        Parameters:
        str - question to ask
        defVal - default value
        Returns:
        true