- We no longer coerce the type of an option
default
to match that of itstype
argument whenaction = "callback"
. Thanks husheng (@hs3434) for bug report (#47).
- Revises vignette engine specification in the
DESCRIPTION
to suppress new CRAN check NOTE (#43).
-
The errors raised by
parse_args()
(andparse_args2()
) are now of class "optparse_parse_error".When
interactive()
isFALSE
we now print out a usage string followed by a (less verbose) error message. -
Throws a more informative error message for unknown short flags when
positional_arguments=TRUE
. Thanks Greg Minshall for bug report (#42).
- Add a
formatter
argument toOptionParser()
for a function to format the usage message (#30). By default uses the new functionIndentedHelpFormatter()
.{optparse}
also provides the new functionTitledHelpFormatter()
. Thanks Ni Huang for suggestion.
- Throws an error for unknown short flags and long flags when
positional_arguments=TRUE
. Thanks Greg Minshall for bug report (#34). - If the
callback
parameter ofadd_option
/make_option
is notNULL
then the default ofaction
is now"callback"
. Thanks Greg Minshall for suggestion (#35). - Better documentation of
action=="callback"
in the man page foradd_option
andmake_option
. Thanks Greg Minshall for bug report (#35).
- Fixes bug in printing help for
action=="callback"
whenmetavar==NULL
(#29). Thanks Ni Huang for bug report. - Throws an error when passed short flags more than one letter long (#32). Thanks Gautier Richard for bug report.
- Fixs a parsing bug when
action=="callback"
andpositional_argument==TRUE
(#28). Thanks Ni Huang for bug report.
- Improves accuracy of README (#27). Thanks Alex Penson for bug report.
- Supports callback actions (#26). Thanks Gyu Jin Choi for patch.
- If
interactive() == FALSE
andprint_help_and_exit == TRUE
thenoptparse
will now callquit(status=0)
instead ofquit(status=1)
after printing the help message (this matches behaviour of the python package). - Better error message when forgetting to set
add_help_option=FALSE
when defining an-h
or--help
flag. Thanks Jeff P. Bruce for bug report. - Increment
getopt
requirement so that empty strings are parsed correctly. Thanks Matthew Flickinger for bug report.
- Minor documentation fixes. Thanks J. J. Ramsey and Daeyoung Kim for bug reports.
- Fix bug when
add_help_option
inOptionParser
set toFALSE
. Thanks to Jeff Bruce for bug report. parse_args
now supportsconvert_hyphens_to_underscores
argument which converts any hyphens to underscores when returning the list of options- Now includes the convenience function
parse_args2
which wrapsparse_args
withpositional_arguments
set toTRUE
andconvert_hyphens_to_underscores
set toTRUE
.
optparse
should no longer give any warnings whenoptions(warnPartialMatchArgs=TRUE)
. Thanks Rich FitzJohn for patch.print_help
no longer throws an error if we have a default argument of length zero. Thanks Benjamin Tyner for bug report.
OptionParser
andOptionParserOption
S4 classes are now exported. Thanks Peter Humburg for patch.
- Parameter
positional_arguments
of functionparse_args
now accepts one or two numeric values that denote the minimum and maximum number of supported positional arguments. Thanks Kirill Müller for patch. - If
interactive() == TRUE
thenparse_args
will no longerquit(status=1)
after printing a help message but will instead throw an error.optparse
will continue toquit(status=1)
after printing a help message for non-interactive Rscripts unlessprint_help_and_exit == FALSE
. - In
make_option
argumenttype="numeric"
automatically cast todouble
. Previously users might have received an error passing negative numbers if they accidentally specified "numeric" instead of "double". - Bug fixed in printing usage message for options with default value of NA and a help string including "%default". Thanks Stefan Seemayer for bug report and patch.
- Project website moved to https://github.com/trevorld/optparse
- We now replace all occurrences of %prog in usage message (including description and epilogue). Previously we would only replace one occurrence and didn't make replacements in description and epilogue.
- Fix bug in
parse_args
when we have options with no short flag and positional_arguments=TRUE. Thanks Miroslav Posta for bug report.
- Added
description
andepilogue
arguments toOptionParser
to allow users to add more information to generated help messages - Slightly alters the generated usage string to match more closely what the Python module does
- No longer exports S4 classes that represent OptionParser and OptionParserOption
- Now requires package getopt (>= 1.19) which has also been moved to Imports field from Depends field in DESCRIPTION
- Now also Suggests stringr package in DESCRIPTION