public interface CommandManager extends ArgumentConverterStore
EMPTY
Modifier and Type | Method and Description |
---|---|
default boolean |
containsCommand(java.lang.String name)
Determine if this manager knows of a command with name
name . |
default int |
execute(InjectedValueAccess context,
java.util.List<java.lang.String> args)
Execute a command, given a set of arguments and a context.
|
java.util.stream.Stream<Command> |
getAllCommands()
Retrieve all commands that are registered.
|
java.util.Optional<Command> |
getCommand(java.lang.String name)
Get the command with name
name , if registered. |
com.google.common.collect.ImmutableSet<Suggestion> |
getSuggestions(InjectedValueAccess context,
java.util.List<java.lang.String> args)
Suggest inputs based on a current user input.
|
Command.Builder |
newCommand(java.lang.String name)
Create a new command builder, using the default implementation of this manager.
|
CommandParseResult |
parse(InjectedValueAccess context,
java.util.List<java.lang.String> args)
Parse a command, given a set of arguments and a context.
|
void |
register(Command command)
Registers any command, regardless of how it came about.
|
default void |
register(java.lang.String name,
java.util.function.Consumer<Command.Builder> registrationProcess)
Register a command that initially has the given name, and then is configured by a function.
|
default void |
registerManager(CommandManager manager)
Register an entire manager with this one, inheriting all of its commands.
|
registerConverter, registerConverters
getConverter, keySet
Command.Builder newCommand(java.lang.String name)
This does not register the command.
void register(Command command)
Use this if you do not want to use the default command implementation of this manager.
command
- the command to registerdefault void register(java.lang.String name, java.util.function.Consumer<Command.Builder> registrationProcess)
name
- the name of the commandregistrationProcess
- a function that will build the commanddefault void registerManager(CommandManager manager)
java.util.stream.Stream<Command> getAllCommands()
default boolean containsCommand(java.lang.String name)
name
.
Includes aliases.
name
- the name to checktrue
if a command has this name, either primarily or by aliasjava.util.Optional<Command> getCommand(java.lang.String name)
name
, if registered.
Includes aliases.
name
- the name to checkOptional.of(Object)
the command if registered,
otherwise Optional.empty()
com.google.common.collect.ImmutableSet<Suggestion> getSuggestions(InjectedValueAccess context, java.util.List<java.lang.String> args)
context
- the injected value contextargs
- the command line to suggest intoCommandParseResult parse(InjectedValueAccess context, java.util.List<java.lang.String> args)
Argument zero is the command name, without any leading slash. The rest of the arguments will be parsed into the correct parts.
Note: Command conditions must pass when encountered, e.g. the root command condition will be tested before parsing its arguments. This is to ensure no information is leaked about sub-commands, etc. while parsing. This also means that there is no need to validate conditions after calling this method, unless you wish to use a different context.
context
- the injected value contextargs
- the arguments to includedefault int execute(InjectedValueAccess context, java.util.List<java.lang.String> args)
Argument zero is the command name, without any leading slash. The rest of the arguments will be parsed into the correct parts.
context
- the injected value contextargs
- the arguments to include