Closed Fyorl closed 8 years ago
You can use ParsedArguments#wasGiven to detect this. The reason ParsedArguments.get() is @Nullable is that sometimes null is used as the default. Having both default values and Optional is confusing IMO so that's why I made it nullable instead of Optional. My thought was that either you make it required or you have a default value.
That's my fault for not reading the documentation thoroughly, thank you for the response.
I would appreciate it if you closed this issue:)
Sorry, thought I already had.
If you create a
NumberType
argument such asbigDecimalArgument
orintegerArgument
and you do not specify it asrequired()
then there is no way, within your program, to tell if the user has invoked your program with the argument or not. Since allNumberType
arguments inherit adefaultValue()
of 0, your program cannot tell if the user has specified 0 at the command line or if the user did not specify a number at all.This behaviour does not strike me as particularly intuitive as there can be a very large semantic difference between a user specifying a value and a user omitting a value entirely.
Since
ParsedArguments.get()
is marked as@Nullable
, I propose that this returnnull
for an argument that is notrequired()
, has no explicitdefaultValue()
and has not been provided a value on the command line. IdeallyParsedArguments.get()
should return anOptional
though.