Releases: trevorld/r-optparse
Release list
optparse 1.8.2
New features
-
add_option()(andmake_option()) now support the following new actions (#22):action = "append"which appends each occurrence's value todefault.action = "append_const"which appendsconsttodefaulteach time the flag is seen.action = "count", which counts the number of times a flag is seen and adds it todefault(treated as0Lif not supplied). ReturnsNULLif the flag is never seen and nodefaultwas supplied.action = "store_const"which storesconstwhen the flag is seen.
-
add_option()(andmake_option()) now support aconstparameter (intended for new actions"append_const"and"store_const"). -
Several new classed errors are now thrown, mirroring Python's
optparseexception hierarchy:-
optparse_option_error: invalid option definition inmake_option()oradd_option().optparse_option_conflict_error: duplicate flag inOptionParser()oradd_option().
-
optparse_parse_error: existing base class for all parse-time errors fromparse_args().optparse_bad_option_error: unrecognized, misused, or argument-requiring option.optparse_ambiguous_option_error: ambiguous abbreviated long flag.
optparse_bad_positional_arguments_error: wrong number of positional arguments supplied.optparse_missing_required_error: a required option was not supplied.
-
-
add_option()(andmake_option()) now allow non-letter characters in short flags (e.g.,-1) and at the beginning of long flags (e.g.,--1flag), following Python'soptparseconvention. However long and short flags may not contain=or whitespace (or begin with hyphens). -
add_option()(andmake_option()) now support arequiredargument.
IfTRUE,parse_args()will throw an error if the option is not provided on the command line (#17).
Bug fixes and minor improvements
parse_args()(andparse_args2()) now correctly handle a bare--separator: all arguments after--are treated as positional arguments rather than options.parse_args()(andparse_args2()) now support abbreviated long flags (e.g.--verbmatching--verbose) whenpositional_argumentsis notFALSE. Previously abbreviations were only supported whenpositional_arguments = FALSE.make_option()now throws a classedoptparse_option_errorfor invalidactionortypearguments instead of a confusing error later at parse time.OptionParser()now also checks theLITTLER_SCRIPT_PATHenvironment variable for the script name when performing%progon theusageargument so it works when called fromlittler.
optparse 1.7.5
optparse 1.7.4
- Revises vignette engine specification in the
DESCRIPTIONto suppress new CRAN check NOTE (#43).
optparse 1.7.3
-
The errors raised by
parse_args()(andparse_args2()) are now of class "optparse_parse_error".When
interactive()isFALSEwe 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).
optparse 1.7.1
- Add a
formatterargument 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.
optparse 1.6.6
- Throws an error for unknown short flags and long flags when
positional_arguments=TRUE.
Thanks Greg Minshall for bug report (#34). - If the
callbackparameter ofadd_option/make_optionis notNULLthen
the default ofactionis now"callback". Thanks Greg Minshall for suggestion (#35). - Better documentation of
action=="callback"in the man page foradd_optionandmake_option.
Thanks Greg Minshall for bug report (#35).
optparse 1.6.4
optparse 1.6.2
- Fixs a parsing bug when
action=="callback"andpositional_argument==TRUE(#28). Thanks Ni Huang for bug report.
optparse 1.6.1
- Improve accuracy of README (#27). Thanks Alex Penson for bug report.
optparse 1.6.0
- Support for callback actions (#26). Thanks Gyu Jin Choi for patch.