Closed sseemayer closed 10 years ago
First pull request I've received since moving to Github :-) I decided to move the logic of converting a default into a string into a helper function so I'm going to close the pull request without pulling in your exact patch but I've fixed the bug, added some unit tests, and thanked you in the documentation and NEWS file and have pushed those updates to the main branch.
Thanks,
Trevor
Your solution is a lot better than mine - thanks for the quick response!
Hi Trevor,
Thank you for great port of optparse to R! I've realized today that when defining an option with a default value of
NA
, the help message printed by the-h
switch will not show a help text for this option. Consider e.g. the following minimal example:Running this from the command line I get:
I've traced this to the sub call for replacing the
%default
variable in the help text. When the replacement isNA
, the whole returned string will beNA
(the constant, not the string!). The replacement isNA
becauseas.character(NA) = NA
, not"NA"
as expected.The pull request adds a check for
NA
in thedefault_str
to check for this corner case and replaceNA
with"NA"
so that the help text can be correctly formatted.Best, Stefan