Package io.dropwizard.core.cli
Class Command
- java.lang.Object
-
- io.dropwizard.core.cli.Command
-
- Direct Known Subclasses:
ConfiguredCommand
public abstract class Command extends Object
A basic CLI command.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
configure(net.sourceforge.argparse4j.inf.Subparser subparser)
Configure the command'sSubparser
.String
getDescription()
Returns the command's description.String
getName()
Returns the command's name.void
onError(Cli cli, net.sourceforge.argparse4j.inf.Namespace namespace, Throwable e)
Method is called if there is an issue parsing configuration, setting up the environment, or running the command itself.abstract void
run(Bootstrap<?> bootstrap, net.sourceforge.argparse4j.inf.Namespace namespace)
Executes when the user runs this specific command.
-
-
-
Method Detail
-
getName
public final String getName()
Returns the command's name.- Returns:
- the command's name
-
getDescription
public final String getDescription()
Returns the command's description.- Returns:
- the command's description
-
configure
public abstract void configure(net.sourceforge.argparse4j.inf.Subparser subparser)
Configure the command'sSubparser
.- Parameters:
subparser
- theSubparser
specific to the command
-
run
public abstract void run(Bootstrap<?> bootstrap, net.sourceforge.argparse4j.inf.Namespace namespace) throws Exception
Executes when the user runs this specific command.- Parameters:
bootstrap
- the bootstrapnamespace
- the parsed command line namespace- Throws:
Exception
- if something goes wrong
-
onError
public void onError(Cli cli, net.sourceforge.argparse4j.inf.Namespace namespace, Throwable e)
Method is called if there is an issue parsing configuration, setting up the environment, or running the command itself. The default is printing the stacktrace to facilitate debugging, but can be customized per command.- Parameters:
cli
- contains the streams for stdout and stderrnamespace
- the parsed arguments from the commandlinee
- The exception that was thrown when setting up or running the command
-
-