CLI
stands for command Line Interface. Commons CLI support different kinds of
options.
a. POSIX like options
(ie. tar -zxvf foo.tar.gz)
b. GNU like long options
(ie. du --human-readable --max-depth=1)
c. Java like properties
(ie. java -Djava.awt.headless=true -Djava.net.useSystemProxies=true Foo)
d. Short options with
value attached (ie. gcc -O2 foo.c)
e. long options with
single hyphen (ie. ant -projecthelp)
By
using Commons CLI library, you can generate help for any command line tool,
parse the command line arguments, query the command line arguments.
Typical
CLI output looks like below.
usage: FileCopy -i <FILE PATH> -o <FILE PATH> [-help] [-version] [-quiet] [-verbose] [-debug] [-lang <LANGUAGE>] -i,--input <FILE PATH> input file to read data from -o,--output <FILE PATH> output file to write the final result -help print this message -version print the version information and exit -quiet be extra quiet -verbose be extra verbose -debug print debugging information -lang,--language <LANGUAGE> Encoding Langauge
Later
posts explain each and every concept in detail.
- Specify single command line option
- Set the display name for the argument
- Define options using builder
- Options class
- Boolean options
- Add multiple arguments to an option
- Setting the compulsory options
- Print command line argument in the order you inserted
- Parsing command line options
- Group mutually Exclusive options
No comments:
Post a Comment