Hi,
I want to use CLI (version 1.2) to parse Java like properties,
ie. java -DnodeName=MyServer -DnodeIp=10.1.2.2 -DnodePort=1003
here is my test code:
Option helpOp = new Option("h", "command line help");
Option nodeNameOp = OptionBuilder.withArgName( "nodeName=value" )
.hasArgs(2)
.withValueSeparator()
.withDescription( "the server name" )
.create( "D" );
Option nodeIpOp = OptionBuilder.withArgName( "nodeIp=value" )
.hasArgs(2)
.withValueSeparator()
.withDescription( "server ip" )
.create( "D" );
Option nodePortOp = OptionBuilder.withArgName( "nodePort=value" )
.hasArgs(2)
.withValueSeparator()
.withDescription( "server port" )
.create( "D" );
Options cmdOptions = new Options();
cmdOptions.addOption(helpOp);
cmdOptions.addOption(nodeNameOp);
cmdOptions.addOption(nodeIpOp);
cmdOptions.addOption(nodePortOp);
HelpFormatter helpFormatter = new HelpFormatter();
helpFormatter.printHelp("command line help", cmdOptions);
and here is the output:
usage: command line help
-D <nodePort=value> server port
-h command line help
Why the help displays only "NodePort"?
Could anybody give me an example code to use CLI for Java properties?
Thanks
Joey Lv
12/24/2011