public interface CommandContext
Modifier and Type | Method and Description |
---|---|
void |
addEventListener(CliEventListener listener)
Adds a listener for CLI events.
|
org.jboss.dmr.ModelNode |
buildRequest(String line)
Builds a DMR request corresponding to the command or the operation.
|
void |
clearScreen()
Clears the screen.
|
void |
connectController(String host,
int port)
Connects the controller client using the host and the port.
|
void |
disconnectController()
Closes the previously established connection with the controller client.
|
void |
error(String message)
This method invokes error(message, 1).
|
void |
error(String message,
int code)
Prints an error message to the CLI's output and passes the error code
which in non-interactive mode will be used as the program's exit code.
|
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.
|
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.
|
CommandLineCompleter |
getDefaultCommandCompleter()
Returns the default command line completer.
|
String |
getDefaultControllerHost()
Returns the default host the controller client will be connected to
in case the host argument isn't specified.
|
int |
getDefaultControllerPort()
Returns the default port the controller client will be connected to
in case the port argument isn't specified.
|
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.
|
OperationCandidatesProvider |
getOperationCandidatesProvider()
Returns the provider of operation request candidates for tab-completion.
|
ParsedCommandLine |
getParsedCommandLine()
Parsed command line arguments.
|
OperationRequestAddress |
getPrefix()
Returns the current prefix.
|
PrefixFormatter |
getPrefixFormatter()
Returns the prefix formatter.
|
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 |
isTerminated()
Checks whether the session has been terminated.
|
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 |
set(String key,
Object value)
Associates an object with key.
|
void |
setCurrentDir(File dir)
Changes the current default filesystem directory to the argument.
|
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 error(String message, int code)
message
- the error messagecode
- the error code (should be greater than 0)void error(String message)
message
- the error messagevoid 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 forModelControllerClient getModelControllerClient()
void connectController(String host, int port)
host
- the host to connect withport
- the port to connect onvoid disconnectController()
String getDefaultControllerHost()
int getDefaultControllerPort()
String getControllerHost()
int getControllerPort()
CommandLineParser getCommandLineParser()
OperationRequestAddress getPrefix()
PrefixFormatter getPrefixFormatter()
OperationCandidatesProvider getOperationCandidatesProvider()
CommandHistory getHistory()
boolean isBatchMode()
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 directoryCopyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.