Interface CommandContext
- All Known Implementing Classes:
CommandContext.DefaultCommandContext
public interface CommandContext
Interface containing information about current command execution.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets a command registration.<T> T
getOptionValue
(String name) Gets an mapped option value.Gets a command option parser results.String[]
Gets a raw args passed into a currently executing command.Gets aShellContext
associated withCommandContext
.org.jline.terminal.Terminal
Gets a terminal.boolean
hasMappedOption
(String name) Gets if option has been mapped.static CommandContext
of
(String[] args, CommandParser.CommandParserResults results, org.jline.terminal.Terminal terminal, CommandRegistration commandRegistration, ShellContext shellContext) Gets an instance of a defaultCommandContext
.
-
Method Details
-
getRawArgs
String[] getRawArgs()Gets a raw args passed into a currently executing command.- Returns:
- raw command arguments
-
hasMappedOption
Gets if option has been mapped.- Parameters:
name
- the option name- Returns:
- true if option has been mapped, false otherwise
-
getParserResults
CommandParser.CommandParserResults getParserResults()Gets a command option parser results.- Returns:
- the command option parser results
-
getCommandRegistration
CommandRegistration getCommandRegistration()Gets a command registration.- Returns:
- the command registration
-
getOptionValue
Gets an mapped option value.- Type Parameters:
T
- the type to map to- Parameters:
name
- the option name- Returns:
- mapped value
-
getTerminal
org.jline.terminal.Terminal getTerminal()Gets a terminal.- Returns:
- a terminal
-
getShellContext
ShellContext getShellContext()Gets aShellContext
associated withCommandContext
.- Returns:
- a shell context
-
of
static CommandContext of(String[] args, CommandParser.CommandParserResults results, org.jline.terminal.Terminal terminal, CommandRegistration commandRegistration, ShellContext shellContext) Gets an instance of a defaultCommandContext
.- Parameters:
args
- the argumentsresults
- the resultsterminal
- the terminalcommandRegistration
- the command registration- Returns:
- a command context
-