import com.cli_parser.CLI; import com.cli_parser.CommandLine; public class MyApp { @CLI.Option(name = "-name", description = "The name of the user", required = true) private String name; @CLI.Option(name = "-age", description = "The age of the user", required = true) private int age; public static void main(String[] args) { MyApp app = new MyApp(); try { CLI.parse(args, app); System.out.println("Hello, " + app.name + "! You are " + app.age + " years old."); } catch (CommandLine.InvalidArgumentException e) { System.err.println(e.getMessage()); CLI.printUsage(app); } } }


上一篇:
下一篇:
切换中文