The Apache Commons CLI library provides an API for parsing command line options passed to programs. It's also able to print help messages detailing the options available for a command line tool.
Commons CLI supports different types of options:
tar -zxvf foo.tar.gz)du --human-readable --max-depth=1)java -Djava.awt.headless=true -Djava.net.useSystemProxies=true Foo)gcc -O2 foo.c)ant -projecthelp)A typical help message displayed by Commons CLI looks like this:
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
--block-size <SIZE> use SIZE-byte blocks
-c with -lt: sort by, and show, ctime (time of last
modification of file status information) with
-l:show ctime and sort by name otherwise: sort
by ctime
-C list entries by columns
Check out the introduction page for a detailed presentation.
Commons CLI 1.0 was formed from the merger of ideas and code from three different libraries - Werken, Avalon and Optz. In dealing with the bugs and the feature requests a freshly designed and not backwards compatible CLI 2 was created, but never finished or released. Since then bugfix releases have been made for CLI 1.
The current plan is to maintain the 1.x line until CLI 2 is officially released. The 2.x design is generally preferred and is in use, however there is no current activity to make a 2.0 release. To this end, the 1.2 release is recommended to most users while the 2.x line is recommended for anyone interested in helping to get this better API released.
A full User's Guide is available as are various project reports .
The Javadoc API documents are available online:
The Subversion repository can be browsed .
The latest version is v1.2. -
Download now!
The release notes
are also available.
For previous releases, see the Apache Archive .
The commons mailing lists
act as the main support forum. The user list
is suitable for most library usage queries. The dev list is intended for the development discussion. Please
remember that the lists are shared between all commons components, so prefix your email subject by
[cli].
Issues may be reported via the ASF JIRA .