Dear Members,
I just write this e-mail to share with all of you about my solution. It is
simple just to use the CLI 2.0. You can download the version on:
http://cvs.apache.org/builds/jakarta-commons/nightly/commons-cli/
on the following web page there is a pre-release information about it:
http://people.apache.org/~roxspring/cli/docs/
and the module 12 of the book:
http://www.manning.com/goyal/
would help.
With this version I have no found any of the problems I have commented on my
e-mail.
David
David <[EMAIL PROTECTED]> wrote:
Dear member,
I am starting to use CLI tools, and I have found the following problems:
Defining an Option that expect an argument with '=' as separator, on the output
of printHelp I don't get on the syntax the = separator symbol, instead I get a
single space.
Option with argument, short and long option value, and equal symbol as
separator, I can use the =-separator for long option but not for short one (for
this case I have to use space).
Option with long and short value, but the short option is not a character (more
than one character), on the printHelp method is reconized as a short option,
and even I can use with the method CommandLine.hasOption(shortOption) but not
as input line argument.
This is the code I have:
Option inputDir = new Option("-i", "inputDir", true, "inputDir description");
opt.setValueSeparator('=');
opt.setArgName("dir");
and
Option mFile = new Option("mFile", "movement-file, true, "mFile description);
opt.setValueSeparator('=');
opt.setArgName("file");
so mFile option has as short opt the value: "mFile", on the output I get:
-mFile,--movement-file mFile description
-i,--inputDir inputDir description
so I dont' get the equal symbol as separator.
the automatic syntax is also with spaces:
usage: com.schinvest.lra.business.batch.BatchCaller.main [options]
[
...
] [-i dir] [-mFile file]
Testing, the following situations fails agains assertEquals("input",
line.getOptionValue("i")):
args = new String[] { "-i=input" } => fails
args = new String[] { "-i", "=input" } => fails
but
args = new String[] { "--input-dir=input" } => true
args = new String[] { "-iinput" } => true
args = new String[] { "-i", "input" } => true
testing now mFile, with:
assertEquals("file", line.getOptionValue("mFile")):
we get:
args = new String[] { "-mFile", "file" } => Unknown F option
but
args = new String[] { "--movement-file=file" } => true
Is it a bug or I am doing something wrong. I am using CLI 1.0.
Thanks in advance,
David
---------------------------------
Blab-away for as little as 1ยข/min. Make PC-to-Phone Calls using Yahoo!
Messenger with Voice.
---------------------------------
Yahoo! Mail goes everywhere you do. Get it on your phone.