public interface Command extends Closeable
Modifier and Type | Method and Description |
---|---|
default void |
close()
Used to close resources created by commands.
|
String |
getCommandName()
Gets the command name as input from the shell.
|
String |
getDescription() |
default org.apache.commons.cli.Options |
getOptions() |
default Map<String,Command> |
getSubCommands() |
String |
getUsage() |
default boolean |
hasSubCommand()
If a command has sub-commands, the first argument should be the sub-command's name,
all arguments and options will be parsed for the sub-command.
|
default org.apache.commons.cli.CommandLine |
parseAndValidateArgs(String... args)
Parses and validates the arguments.
|
default int |
run(org.apache.commons.cli.CommandLine cl)
Runs the command.
|
default void |
validateArgs(org.apache.commons.cli.CommandLine cl)
Checks if the arguments are valid or throw InvalidArgumentException.
|
String getCommandName()
default org.apache.commons.cli.Options getOptions()
Options
of the commanddefault boolean hasSubCommand()
default Map<String,Command> getSubCommands()
default org.apache.commons.cli.CommandLine parseAndValidateArgs(String... args) throws InvalidArgumentException
args
- the arguments for the command, excluding the command nameInvalidArgumentException
- when arguments are not validdefault void validateArgs(org.apache.commons.cli.CommandLine cl) throws InvalidArgumentException
cl
- the parsed command line for the argumentsInvalidArgumentException
- when arguments are not validdefault int run(org.apache.commons.cli.CommandLine cl) throws AlluxioException, IOException
cl
- the parsed command line for the argumentsAlluxioException
IOException
String getUsage()
String getDescription()
default void close() throws IOException
close
in interface AutoCloseable
close
in interface Closeable
IOException
- if closing resources failsCopyright © 2023. All Rights Reserved.