Skip to content

Releases: trevorld/r-optparse

optparse 1.8.2

Choose a tag to compare

@trevorld trevorld released this 17 Apr 17:14

New features

  • add_option() (and make_option()) now support the following new actions (#22):

    • action = "append" which appends each occurrence's value to default.
    • action = "append_const" which appends const to default each time the flag is seen.
    • action = "count", which counts the number of times a flag is seen and adds it to default (treated as 0L if not supplied). Returns NULL if the flag is never seen and no default was supplied.
    • action = "store_const" which stores const when the flag is seen.
  • add_option() (and make_option()) now support a const parameter (intended for new actions "append_const" and "store_const").

  • Several new classed errors are now thrown, mirroring Python's optparse exception hierarchy:

    • optparse_option_error: invalid option definition in make_option() or add_option().

      • optparse_option_conflict_error: duplicate flag in OptionParser() or add_option().
    • optparse_parse_error: existing base class for all parse-time errors from parse_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() (and make_option()) now allow non-letter characters in short flags (e.g., -1) and at the beginning of long flags (e.g., --1flag), following Python's optparse convention. However long and short flags may not contain = or whitespace (or begin with hyphens).

  • add_option() (and make_option()) now support a required argument.
    If TRUE, parse_args() will throw an error if the option is not provided on the command line (#17).

Bug fixes and minor improvements

  • parse_args() (and parse_args2()) now correctly handle a bare -- separator: all arguments after -- are treated as positional arguments rather than options.
  • parse_args() (and parse_args2()) now support abbreviated long flags (e.g. --verb matching --verbose) when positional_arguments is not FALSE. Previously abbreviations were only supported when positional_arguments = FALSE.
  • make_option() now throws a classed optparse_option_error for invalid action or type arguments instead of a confusing error later at parse time.
  • OptionParser() now also checks the LITTLER_SCRIPT_PATH environment variable for the script name when performing %prog on the usage argument so it works when called from littler.

optparse 1.7.5

Choose a tag to compare

@trevorld trevorld released this 17 Apr 03:41
  • We no longer coerce the type of an option default to match that of
    its type argument when action = "callback".
    Thanks husheng (@hs3434) for bug report (#47).

optparse 1.7.4

Choose a tag to compare

@trevorld trevorld released this 17 Jan 00:13
  • Revises vignette engine specification in the DESCRIPTION to suppress new CRAN check NOTE (#43).

optparse 1.7.3

Choose a tag to compare

@trevorld trevorld released this 20 Jul 18:42
  • The errors raised by parse_args() (and parse_args2()) are now of class "optparse_parse_error".

    When interactive() is FALSE 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).

optparse 1.7.1

Choose a tag to compare

@trevorld trevorld released this 08 Oct 19:52
  • Add a formatter argument to OptionParser() for a function to format the usage message (#30).
    By default uses the new function IndentedHelpFormatter().
    {optparse} also provides the new function TitledHelpFormatter().
    Thanks Ni Huang for suggestion.

optparse 1.6.6

Choose a tag to compare

@trevorld trevorld released this 16 Apr 23:07
  • 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 of add_option / make_option is not NULL then
    the default of action is now "callback". Thanks Greg Minshall for suggestion (#35).
  • Better documentation of action=="callback" in the man page for add_option and make_option.
    Thanks Greg Minshall for bug report (#35).

optparse 1.6.4

Choose a tag to compare

@trevorld trevorld released this 16 Sep 21:37
  • Fixes bug in printing help for action=="callback" when metavar==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.

optparse 1.6.2

Choose a tag to compare

@trevorld trevorld released this 02 Apr 20:29
  • Fixs a parsing bug when action=="callback" and positional_argument==TRUE (#28). Thanks Ni Huang for bug report.

optparse 1.6.1

Choose a tag to compare

@trevorld trevorld released this 15 Jan 21:20
  • Improve accuracy of README (#27). Thanks Alex Penson for bug report.

optparse 1.6.0

Choose a tag to compare

@trevorld trevorld released this 18 Jun 03:54
  • Support for callback actions (#26). Thanks Gyu Jin Choi for patch.