Package org.jboss.as.cli.handlers
Class CommandHandlerWithHelp
- java.lang.Object
-
- org.jboss.as.cli.handlers.CommandHandlerWithArguments
-
- org.jboss.as.cli.handlers.CommandHandlerWithHelp
-
- All Implemented Interfaces:
CommandHandler
- Direct Known Subclasses:
ASModuleHandler,BaseOperationCommand,BatchClearHandler,BatchDiscardHandler,BatchEditLineHandler,BatchHandler,BatchHoldbackHandler,BatchListHandler,BatchMoveLineHandler,BatchRemoveLineHandler,CatchHandler,ClearScreenHandler,CommandCommandHandler,CommandTimeoutHandler,ConnectionInfoHandler,DoneHandler,EchoDMRHandler,EchoVariableHandler,ElseHandler,EndIfHandler,EndTryHandler,FinallyHandler,ForHandler,HistoryHandler,IfHandler,PrefixHandler,PrintWorkingNodeHandler,QuitHandler,SetVariableHandler,TryHandler,UnsetVariableHandler
public abstract class CommandHandlerWithHelp extends CommandHandlerWithArguments
Abstract handler that checks whether the argument is '--help', in which case it tries to locate file [cmd].txt and print its content. If the argument is absent or isn't '--help', it'll call doHandle(ctx) method.- Author:
- Alexey Loubyansky
-
-
Field Summary
Fields Modifier and Type Field Description protected ArgumentWithoutValuehelpArg
-
Constructor Summary
Constructors Constructor Description CommandHandlerWithHelp(String command)CommandHandlerWithHelp(String command, boolean connectionRequired)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voiddisplayHelp(CommandContext ctx)protected abstract voiddoHandle(CommandContext ctx)voidhandle(CommandContext ctx)Executes the command.booleanisAvailable(CommandContext ctx)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)booleanisBatchMode(CommandContext ctx)Whether the command supports batch mode or not.protected voidprintHelp(CommandContext ctx)protected voidprintList(CommandContext ctx, Collection<String> list, boolean l)Prints a list of strings.-
Methods inherited from class org.jboss.as.cli.handlers.CommandHandlerWithArguments
addArgument, getArgument, getArguments, getArgumentsMap, hasArgument, hasArgument, recognizeArguments
-
-
-
-
Field Detail
-
helpArg
protected ArgumentWithoutValue helpArg
-
-
Method Detail
-
isAvailable
public boolean isAvailable(CommandContext ctx)
Description copied from interface:CommandHandlerChecks 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:CommandHandlerExecutes 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.
-
displayHelp
public void displayHelp(CommandContext ctx) throws CommandLineException
- Throws:
CommandLineException
-
printHelp
protected void printHelp(CommandContext ctx) throws CommandLineException
- Throws:
CommandLineException
-
doHandle
protected abstract void doHandle(CommandContext ctx) throws CommandLineException
- Throws:
CommandLineException
-
isBatchMode
public boolean isBatchMode(CommandContext ctx)
Description copied from interface:CommandHandlerWhether 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 contextlist- the list to print
-
-