You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by David <ac...@yahoo.es> on 2006/04/17 11:16:42 UTC

[CLI]: Strange behaviour with = separator and string short options (possible bug)

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.

Re: [CLI]: Strange behaviour with = separator and string short options (possible bug)

Posted by Henri Yandell <fl...@gmail.com>.
Thanks for following the email up with your solution David.

Hopefully we can start things moving with regards to CLI 2.0 and get
it released in a few months time.

Hen

On 4/24/06, David <ac...@yahoo.es> wrote:
> 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 <ac...@yahoo.es> 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.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [CLI]: Strange behaviour with = separator and string short options (possible bug)

Posted by David <ac...@yahoo.es>.
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 <ac...@yahoo.es> 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.