Descripción
Create a Picocli command with options
File Template: ✅
Prefix
picocli:options
Scopes
java
Snippet de código
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
@Command(name = "${1:greet}", mixinStandardHelpOptions = true, description = "${2:Greet a person}")
public class ${1:GreetCommand} implements Runnable {
@Option(names = {"-n", "--name"}, description = "The person to greet", required = true)
private String name;
@Option(names = {"-c", "--count"}, description = "Number of greetings")
private int count = 1;
@Override
public void run() {
for (int i = 0; i < count; i++) {
System.out.println("Hello " + name + "!");
}
}
public static void main(String[] args) {
int exitCode = new CommandLine(new ${1:GreetCommand}()).execute(args);
System.exit(exitCode);
}
}