import org.apache.commons.cli.*; public class MyCLIApp { 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("MyCLIApp", options); System.exit(0); } if (cmd.hasOption("f")) { String filePath = cmd.getOptionValue("f"); } else { } } catch (ParseException e) { formatter.printHelp("MyCLIApp", options); System.exit(1); } } }


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