概述
Apache Commons CLI是开源的命令行解析工具,它可以帮助开发者快速构建启动命令,并且帮助你组织命令的参数、以及输出列表等。
commons-cli 支持以下风格的命令行参数解析:
POSIX 风格 如: tar -zxvf foo.tar.gz
GNU 长参数风格: du --human-readable --max-depth=1
Java 属性风格: java -Djava.awt.headless=true -Djava.net.useSystemProxies=true Foo
短杠带参数值风格: ie. gcc -O2 foo.c
通过apache commons cli 能够打印类似如下优雅的帮助信息
usage: ls
-A,--almost-all do not list implied . and ..
-a,--all do not hide entries starting with .
-B,--ignore-backups do not list implied entried ending with ~
-b,--escape print octal escapes for nongraphic characters
--