<dependency> <groupId>com.github.renots</groupId> <artifactId>mainargs</artifactId> <version>0.6.0</version> </dependency> import com.github.renots.mainargs.*; public class MyArgs { @Arg private String input; @Option(name = "-o", description = "Output file") private String output; @Option(name = "-n", description = "Number of times to repeat") private int repeat = 1; // Getters and setters } public class MyApp { public static void main(String[] args) { MyArgs myArgs = new MyArgs(); try { Main.execute(args, myArgs); } catch (ArgumentException e) { System.exit(1); } System.out.println("Input: " + myArgs.getInput()); System.out.println("Output: " + myArgs.getOutput()); System.out.println("Repeat: " + myArgs.getRepeat()); } }


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