If Getopt::Long::Descriptive is installed and any of the following command line parameters are passed, the program will exit with usage information (and the option's state will be stored in the help_flag attribute). You can add descriptions for each option by including a documentation option for each attribute to document.

ARGV

This accessor contains a reference to a copy of the @ARGV array as it originally existed at the time of new_with_options.

extra_argv

This accessor contains an arrayref of leftover @ARGV elements that Getopt::Long did not parse. Note that the real @ARGV is left untouched.

Important: By default, Getopt::Long will reject unrecognized options (that is, options that do not correspond with attributes using the Getopt trait). To disable this, and allow options to also be saved in extra_argv (for example to pass along to another class's new_with_options), you can either enable the pass_through option of Getopt::Long for your class: use Getopt::Long qw(:config pass_through); or specify a value for MooseX::Getopt::GLD's getopt_conf parameter.

usage

help_flag

This accessor contains the boolean state of the --help, --usage and --? options (true if any of these options were passed on the command line).

print_usage_text

This method is called internally when the help_flag state is true. It prints the text from the usage object (see above) to STDOUT (and then after this method is called, the program terminates normally). You can apply a method modification (see Moose::Manual::MethodModifiers) if different behaviour is desired, for example to include additional text.

meta

This returns the role meta object.

process_argv (%params)

This does most of the work of new_with_options, analyzing the parameters and argv, except for actually calling the constructor. It returns a MooseX::Getopt::ProcessedArgv object. new_with_options uses this method internally, so modifying this method via subclasses/roles will affect new_with_options.

This module attempts to DWIM as much as possible with the command line parameters by introspecting your class's attributes. It will use the name of your attribute as the command line option, and if there is a type constraint defined, it will configure Getopt::Long to handle the option accordingly.

By default, attributes which start with an underscore are not given command-line argument support, unless the attribute's metaclass is set to MooseX::Getopt::Meta::Attribute. If you don't want your accessors to have the leading underscore in their name, you can do this:

For example, if you had the same custom ArrayOfInts subtype from the examples above, but did not add a new custom option type for it to the OptionTypeMap, it would be treated just like a normal ArrayRef type for Getopt purposes (that is, =s@).

More Customization Options

Note in particular that the default setting for case sensitivity has changed over time in Getopt::Long::Descriptive, so if you rely on a particular setting, you should set it explicitly, or enforce the version of Getopt::Long::Descriptive that you install.