empty string and null treated equal in usage string

85 views
Skip to first unread message

raschedh

unread,
Jul 24, 2012, 5:55:50 PM7/24/12
to jcomm...@googlegroups.com
I like the fact that the default values of fields are shown in the
usage message.

But when I say

@Parameter(names = "-x")
String s;

or

@Parameter(names = "-x")
String s = "";

Then the empty string is treated as if there were no default value;

If, for example I say

@Parameter(names = "-x")
String s = " "; // one space

then, `Default:' is shown in the usage message.

I have a use case for that (empty message in a cmdline email app, where
I am only interested in the subject and the attachment),
so I would consider that a bug.

What do you think ?

Thanks for your help.

Heinz.

Cédric Beust ♔

unread,
Jul 25, 2012, 5:54:12 PM7/25/12
to jcomm...@googlegroups.com
Hi Heinz,

I just fixed this in master:

Usage: <main class> [options]
  Options:
    -x   
         Default: <empty string>

-- 
Cédric

raschedh

unread,
Jul 25, 2012, 6:06:09 PM7/25/12
to jcomm...@googlegroups.com, ced...@beust.com
Pulled, recompiled and it works.

Great ! Thank you, Cedric.

Very thoughtful and whence cool, that it says <empty string> and not just `Default:'

By the way: Jcommander rocks !

Thanks again.

Heinz.


raschedh

unread,
Jul 26, 2012, 4:36:12 PM7/26/12
to jcomm...@googlegroups.com, ced...@beust.com
Hey Cedric,

I am fully aware that what I am about to say is pedantic.
So if you think, the following is impressively stupid, just
tell me to shut the #$%@ up and I will.
But I can't help my mathematically inclined brain.
It might even be cumbersome to implement.



Wouldn't it be better to say in the usage message
`Defaults to the empty string'
or some such.
Because one might say

@Parameter(names="-x")
String s = "<empty string>"

Sorry for the annoyance.

Heinz.

raschedh

unread,
Aug 1, 2012, 3:14:47 PM8/1/12
to jcomm...@googlegroups.com, ced...@beust.com
Hey,

I'm jealous: jcommanderguy gets all the attention.
And I love jcommander at least as much as him, I bet.

Heinz.

Cédric Beust ♔

unread,
Aug 1, 2012, 3:23:03 PM8/1/12
to jcomm...@googlegroups.com
Hey Heinz,

:-)

I can't find any unresolved issue from you, did I miss something?

-- 
Cédric

raschedh

unread,
Aug 1, 2012, 3:32:15 PM8/1/12
to jcomm...@googlegroups.com, ced...@beust.com
Hi Cedric,


> I can't find any unresolved issue from you, did I miss something?

Yes, but you might think it is pedantic. I don't mind if therefore you
don't want to do something about it.

I suggested to write 'Defaults to the empty string' or some
such in the usage message, because one might say

@Parameter(names={-s})

String s = "<empty string>"


Heinz.

Cédric Beust ♔

unread,
Aug 1, 2012, 3:35:08 PM8/1/12
to jcomm...@googlegroups.com
Yeah I saw that and agreed with you that it was pedantic, so I didn't do anything about it :-)

-- 
Cédric

raschedh

unread,
Aug 1, 2012, 3:53:07 PM8/1/12
to jcomm...@googlegroups.com, ced...@beust.com
Ah, alright. But can't you smell the self reference that lies
in the problem? I love that. And always struggle with that.

Anyhow. Please tolerate (and read) the following paragraph.
I can't help writing it, as I do not only have a high end brain,
but my emotional subsystem is one hell of a machine, too.

I find it deeply impressive, how a man with such an impressive
what-i-wrote-and-where-i-worked history can be so responsive
to a project of his, which userbase is, as I assume arrogantly,
very small.

Thank you for that, Cedric !

I have a lot to learn.

Heinz.

Cédric Beust ♔

unread,
Aug 1, 2012, 4:26:59 PM8/1/12
to jcomm...@googlegroups.com
Thanks for the kind words, Heinz, that's very nice to hear!

-- 
Cédric

Reply all
Reply to author
Forward
0 new messages