public abstract class CliCommand extends Object
public final class Main extends CliCommand {
@Parameter(names = {"--name","-n"}, required = true, description = "an example mandatory parameter")
private String name = null;
// implement the run method
@Override
public void run() {
...
}
// then implement your main entry point like this
public static void main(String... args) {
CommandLineRunner c = new CommandLineRunner();
c.registerSubcommand("daemon", new Main());
c.runOrHelp("punchplatform-shiva.sh", args);
}
}
| Constructor and Description |
|---|
CliCommand() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
printUsage() |
protected abstract void |
run()
The actual execution of the command if all required parameters are here.
|
protected void |
runOrHelp(com.beust.jcommander.JCommander invoker)
This is called from the
CommandLineRunner. |
protected void printUsage()
protected void runOrHelp(com.beust.jcommander.JCommander invoker)
CommandLineRunner.invoker - the invokerprotected abstract void run()
Copyright © 2023. All rights reserved.