33 lines
1.0 KiB
Java
33 lines
1.0 KiB
Java
package me.hatter.demo;
|
|
|
|
import me.hatter.demo.commands.DemoSubCommand;
|
|
import picocli.CommandLine;
|
|
import picocli.CommandLine.Command;
|
|
import picocli.CommandLine.Option;
|
|
|
|
import java.io.File;
|
|
|
|
@Command(name = "example",
|
|
mixinStandardHelpOptions = true,
|
|
version = "Picocli example 1.0",
|
|
subcommands = {
|
|
DemoSubCommand.class
|
|
})
|
|
public class PicocliCli implements Runnable {
|
|
|
|
@Option(names = {"-v", "--verbose"},
|
|
description = "Verbose mode. Helpful for troubleshooting. Multiple -v options increase the verbosity.")
|
|
private boolean[] verbose = new boolean[0];
|
|
|
|
public void run() {
|
|
System.out.println("Use --help for help");
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
// By implementing Runnable or Callable, parsing, error handling and handling user
|
|
// requests for usage help or version help can be done with one line of code.
|
|
int exitCode = new CommandLine(new PicocliCli()).execute(args);
|
|
System.exit(exitCode);
|
|
}
|
|
}
|