public interface CommandContext
Modifier and Type | Method and Description |
---|---|
void |
addEventListener(CliEventListener listener)
Adds a listener for CLI events.
|
void |
bindClient(ModelControllerClient newClient)
Bind the controller to an existing, connected client.
|
org.jboss.dmr.ModelNode |
buildRequest(String line)
Builds a DMR request corresponding to the command or the operation.
|
void |
captureOutput(PrintStream captor)
Redirect output to the given print stream.
|
void |
clearScreen()
Clears the screen.
|
void |
connectController()
Connects the controller client using the default controller definition.
|
void |
connectController(String controller)
Connects to the controller specified.
|
void |
connectController(String host,
int port)
Deprecated.
Use
connectController(String) instead. |
void |
disconnectController()
Closes the previously established connection with the controller client.
|
Object |
get(String key)
Returns the value the key was associated with using the set(key, value) method above.
|
String |
getArgumentsString()
Returns the current command's arguments as a string.
|
BatchManager |
getBatchManager()
Returns batch manager.
|
CommandLineParser |
getCommandLineParser()
Returns the current operation request parser.
|
CliConfig |
getConfig()
Returns the JBoss CLI configuration.
|
ConnectionInfo |
getConnectionInfo()
The ConnectionInfo bean is set after the connection is established to the server.
|
String |
getControllerHost()
Returns the host the controller client is connected to or
null if the connection hasn't been established yet.
|
int |
getControllerPort()
Returns the port the controller client is connected to.
|
File |
getCurrentDir()
Returns current default filesystem directory.
|
OperationRequestAddress |
getCurrentNodePath()
Returns the current prefix.
|
CommandLineCompleter |
getDefaultCommandCompleter()
Returns the default command line completer.
|
ControllerAddress |
getDefaultControllerAddress()
The default address of the default controller to connect to.
|
String |
getDefaultControllerHost()
Deprecated.
Use
getDefaultControllerAddress() instead. |
int |
getDefaultControllerPort()
Deprecated.
Use
getDefaultControllerAddress() instead. |
int |
getExitCode()
Returns value that should be used as the exit code of the JVM process.
|
CommandHistory |
getHistory()
Returns the history of all the commands and operations.
|
ModelControllerClient |
getModelControllerClient()
Returns the model controller client or null if it hasn't been initialized.
|
NodePathFormatter |
getNodePathFormatter()
Returns the prefix formatter.
|
OperationCandidatesProvider |
getOperationCandidatesProvider()
Returns the provider of operation request candidates for tab-completion.
|
ParsedCommandLine |
getParsedCommandLine()
Parsed command line arguments.
|
int |
getTerminalHeight()
Returns the current terminal window height in case the console
has been initialized.
|
int |
getTerminalWidth()
Returns the current terminal window width in case the console
has been initialized.
|
String |
getVariable(String name)
Returns the value for the variable.
|
Collection<String> |
getVariables()
Returns a collection of all the defined variable names.
|
void |
handle(String line)
Executes a command or an operation.
|
void |
handleSafe(String line)
Executes a command or an operation.
|
void |
interact()
This method will start an interactive session.
|
boolean |
isBatchMode()
Checks whether the CLI is in the batch mode.
|
boolean |
isDomainMode()
Indicates whether the CLI is in the domain mode or standalone one (assuming established
connection to the controller).
|
boolean |
isResolveParameterValues()
Command argument or operation parameter values may contain system properties.
|
boolean |
isSilent()
Whether the info or error messages should be written to the terminal output.
|
boolean |
isTerminated()
Checks whether the session has been terminated.
|
boolean |
isWorkflowMode()
Checks whether the CLI is in a workflow mode.
|
void |
printColumns(Collection<String> col)
Prints a collection of strings as columns to the CLI's output.
|
void |
printLine(String message)
Prints a string to the CLI's output.
|
void |
registerRedirection(CommandLineRedirection redirection)
After this method returns command line handling will be redirected to
the passed in CommandLineRedirection instance.
|
void |
releaseOutput()
Stops redirecting output to the stream passed to
captureOutput(java.io.PrintStream) . |
Object |
remove(String key)
Removes the value the key was associated with using the set(key, value) method above.
|
void |
set(String key,
Object value)
Associates an object with key.
|
void |
setCurrentDir(File dir)
Changes the current default filesystem directory to the argument.
|
void |
setResolveParameterValues(boolean resolve)
Command argument or operation parameter values may contain system properties.
|
void |
setSilent(boolean silent)
Enables of disables the silent mode.
|
void |
setVariable(String name,
String value)
Initializes a variable with the given name with the given value.
|
void |
terminateSession()
Terminates the command line session.
|
BatchedCommand |
toBatchedCommand(String line)
Builds an operation request from the passed in command line.
|
CliConfig getConfig()
String getArgumentsString()
ParsedCommandLine getParsedCommandLine()
void printLine(String message)
message
- the message to printvoid printColumns(Collection<String> col)
col
- the collection of strings to print as columns.void clearScreen()
void terminateSession()
boolean isTerminated()
void set(String key, Object value)
key
- the keyvalue
- the value to be associated with the keyObject get(String key)
key
- the key to fetch the value forObject remove(String key)
key
- the key to be removedModelControllerClient getModelControllerClient()
void connectController() throws CommandLineException
CommandLineException
- in case the attempt to connect failedvoid connectController(String controller) throws CommandLineException
controller
- the controller to connect toCommandLineException
- in case the attempt to connect failed@Deprecated void connectController(String host, int port) throws CommandLineException
connectController(String)
instead.host
- the host to connect withport
- the port to connect onCommandLineException
- in case the attempt to connect failedvoid bindClient(ModelControllerClient newClient)
void disconnectController()
@Deprecated String getDefaultControllerHost()
getDefaultControllerAddress()
instead.@Deprecated int getDefaultControllerPort()
getDefaultControllerAddress()
instead.ControllerAddress getDefaultControllerAddress()
String getControllerHost()
int getControllerPort()
CommandLineParser getCommandLineParser()
OperationRequestAddress getCurrentNodePath()
NodePathFormatter getNodePathFormatter()
OperationCandidatesProvider getOperationCandidatesProvider()
CommandHistory getHistory()
boolean isBatchMode()
boolean isWorkflowMode()
BatchManager getBatchManager()
BatchedCommand toBatchedCommand(String line) throws CommandFormatException
line
- the command line which can be an operation request or a command that can be translated into an operation request.CommandFormatException
- if the operation request couldn't be built.org.jboss.dmr.ModelNode buildRequest(String line) throws CommandFormatException
line
- command or an operation to build a DMR request forCommandFormatException
- thrown in case the line couldn't be
translated into a DMR requestCommandLineCompleter getDefaultCommandCompleter()
boolean isDomainMode()
void addEventListener(CliEventListener listener)
listener
- the listenerint getExitCode()
void handle(String line) throws CommandLineException
line
- command or operation to handleCommandFormatException
- in case there was an error handling the command or operationCommandLineException
void handleSafe(String line)
line
- command or operation to handleCommandFormatException
- in case there was an error handling the command or operationvoid interact()
File getCurrentDir()
void setCurrentDir(File dir)
dir
- the new default directoryboolean isResolveParameterValues()
void setResolveParameterValues(boolean resolve)
resolve
- true if system properties in the operation parameter values
should be resolved by the CLI before the request is sent to the controller,
false if system properties should be resolved on the server side.boolean isSilent()
void setSilent(boolean silent)
silent
- true if the CLI should go into the silent mode,
false if the CLI should resume writing info
and error messages to the terminal output.int getTerminalWidth()
int getTerminalHeight()
void setVariable(String name, String value) throws CommandLineException
name
- name of the variablevalue
- value for the variableCommandLineException
- in case the name contains illegal charactersString getVariable(String name)
name
- name of the variableCollection<String> getVariables()
void registerRedirection(CommandLineRedirection redirection) throws CommandLineException
redirection
- command line redirection handlerCommandLineException
- in case registration fails (e.g. in case
one has already been registeredConnectionInfo getConnectionInfo()
void captureOutput(PrintStream captor)
captor
- stream to which output should be written. Cannot be null
IllegalStateException
- if output is already being capturedvoid releaseOutput()
captureOutput(java.io.PrintStream)
.IllegalStateException
- if output isn't currently being capturedCopyright © 2023 JBoss by Red Hat. All rights reserved.