gumdrop_derive 0.3.0

custom derive support for gumdrop
Documentation

Provides derive(Options) for gumdrop crate

derive(Options)

derive(Options) generates an implementation of the trait Options, creating an option for each field of the decorated struct.

See the gumdrop documentation for an example of its usage.

options attribute

Behavior of derive(Options) can be controlled by adding #[options(...)] attributes to one or more fields within a decorated struct.

Supported items are:

  • command indicates that a field represents a subcommand. The field must be of type Option<T> where T is a type implementing Options. Typically, this type is an enum containing subcommand option types.
  • command_name will contain the name of the command selected by the user. Its type must be Option<String>.
  • help_flag marks an option as a help flag. The field must be bool type. Options named help will automatically receive this option.
  • no_help_flag prevents an option from being considered a help flag.
  • count marks a field as a counter value. The field will be incremented each time the option appears in the arguments, i.e. field += 1;
  • free marks a field as the free argument container. Non-option arguments will be appended to this field using its push method.
  • short = "?" sets the short option name to the given character
  • no_short prevents a short option from being assigned to the field
  • long = "..." sets the long option name to the given string
  • no_long prevents a long option from being assigned to the field
  • help = "..." sets help text returned from the Options::usage method
  • meta = "..." sets the meta variable displayed in usage for options which accept an argument