import org.apache.commons.cli.*;
public class MyApp {
public static void main(String[] args) {
Options options = new Options();
CommandLineParser parser = new DefaultParser();
HelpFormatter formatter = new HelpFormatter();
CommandLine cmd;
try {
cmd = parser.parse(options, args);
if (cmd.hasOption("h")) {
formatter.printHelp("myapp", options);
return;
}
if (cmd.hasOption("v")) {
return;
}
} catch (ParseException e) {
formatter.printHelp("myapp", options);
}
}
}
import picocli.CommandLine;
import picocli.CommandLine.*;
@Command(name = "myapp", mixinStandardHelpOptions = true, version = "1.0.0",
public class MyApp implements Runnable {
public void run() {
System.out.println("Hello, World!");
}
public static void main(String[] args) {
CommandLine.run(new MyApp(), args);
}
}