<dependencies> <dependency> <groupId>com.github.alxwhtmr</groupId> <artifactId>optparse</artifactId> <version>0.0.5</version> </dependency> </dependencies> import com.github.alxwhtmr.optparse.Option; import com.github.alxwhtmr.optparse.OptionParser; import com.github.alxwhtmr.optparse.ParseException; public class CommandLineTool { public static void main(String[] args) { OptionParser parser = new OptionParser(); try { parser.parse(args); if (parser.hasOption("help")) { parser.printHelp(); return; } String fileName = parser.getOptionValue("file"); } catch (ParseException e) { } } } java CommandLineTool -f example.txt


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