import org.apache.commons.cli.*; public class MyCLIApp { public static void main(String[] args) { Options options = new Options(); CommandLineParser parser = new DefaultParser(); try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("MyCLIApp", options); } if (cmd.hasOption("f")) { String filePath = cmd.getOptionValue("f"); } } catch (ParseException e) { } } }


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