<dependency> <groupId>org.argot-framework</groupId> <artifactId>argot</artifactId> <version>1.0.0</version> </dependency> import org.argot.*; import org.argot.beans.*; public class CommandLineParserExample { public static void main(String[] args) { OptionSpecification inputOptionSpec = new OptionSpecification(); inputOptionSpec.setIdentifier("-i"); inputOptionSpec.setLongIdentifier("--input-file"); inputOptionSpec.setDescription("Input file path"); CommandLineParser parser = new CommandLineParser(); parser.addOption(inputOptionSpec); ArgotBean argotBean = parser.parse(args); if (argotBean.hasOption(inputOptionSpec)) { String inputFilePath = argotBean.getOption(inputOptionSpec).getValue(); System.out.println("Input file path: " + inputFilePath); } } }


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