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 <file> mFile description
-i,--inputDir <dir> 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] <process_1>
[<process_2> ... <process_n>] [-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.