commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David <>
Subject [CLI]: Strange behaviour with = separator and string short options (possible bug)
Date Mon, 17 Apr 2006 09:16:42 GMT
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");
  Option mFile = new Option("mFile", "movement-file, true, "mFile description);
  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: [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
  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
  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,

Blab-away for as little as 1ยข/min. Make  PC-to-Phone Calls using Yahoo! Messenger with Voice.
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message