Class CommandHandlerWithHelp

    • Constructor Detail

      • CommandHandlerWithHelp

        public CommandHandlerWithHelp​(String command)
      • CommandHandlerWithHelp

        public CommandHandlerWithHelp​(String command,
                                      boolean connectionRequired)
    • Method Detail

      • isAvailable

        public boolean isAvailable​(CommandContext ctx)
        Description copied from interface: CommandHandler
        Checks whether the command is available in the current context (e.g. some commands require connection with the controller, some are available only in the batch mode, etc)
        Parameters:
        ctx - current context
        Returns:
        true if the command can be executed in the current context, false - otherwise.
      • handle

        public void handle​(CommandContext ctx)
                    throws CommandLineException
        Description copied from interface: CommandHandler
        Executes the command.
        Parameters:
        ctx - current command context
        Throws:
        CommandLineException - if for any reason the command can't be properly handled the implementation must throw an instance of CommandLineException.
      • isBatchMode

        public boolean isBatchMode​(CommandContext ctx)
        Description copied from interface: CommandHandler
        Whether the command supports batch mode or not. The result could depend on the context, e.g. it won't make sense to add 'some_command --help' to a batch.
        Parameters:
        ctx - the current context
        Returns:
        true if the command can be added to the batch, otherwise - false.
      • printList

        protected void printList​(CommandContext ctx,
                                 Collection<String> list,
                                 boolean l)
        Prints a list of strings. If -l switch is present then the list is printed one item per line, otherwise the list is printed in columns.
        Parameters:
        ctx - the context
        list - the list to print