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 typeOption<T>
whereT
is a type implementingOptions
. Typically, this type is anenum
containing subcommand option types.help_flag
marks an option as a help flag. The field must bebool
type. Options namedhelp
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 a positional argument field. Non-option arguments will be used to fill allfree
fields, in declared sequence. If the finalfree
field is of typeVec<T>
, it will contain all remaining free arguments.short = "?"
sets the short option name to the given characterno_short
prevents a short option from being assigned to the fieldlong = "..."
sets the long option name to the given stringno_long
prevents a long option from being assigned to the fieldhelp = "..."
sets help text returned from theOptions::usage
methodmeta = "..."
sets the meta variable displayed in usage for options which accept an argument
#[options(...)]
may also be added at the type level. Only the flags
no_help_flag
, no_long
, and no_short
are supported at the type level.