# NAME

Getopt::Inherited - Handling inherited command-line options

# SYNOPSIS

    use base 'Getopt::Inherited';

    use constant GETOPT => qw(foo=s);
    my $app = __PACKAGE__->new;
    $app->do_getopt;

# DESCRIPTION

By subclassing this mixin class, your program gets the ability to inherit
command-line option specifications. If you have several programs that share
common code and common command-line options you don't want to have to write
the command-line processing code again and again. Using this class you can
abstract command-line options shared by your programs into a superclass from
which your programs then inherit. Additionally, this class defines certain
common command-line options itself.

You can also define defaults for command-line options.

# METHODS

- `GETOPT`

This accessor, which is accumulated across the class hierarchy using
[Data::Inherited](http://search.cpan.org/perldoc?Data::Inherited), is used to define command-line options in the same format
as [Getopt::Long](http://search.cpan.org/perldoc?Getopt::Long) expects. This class, [Getopt::Inherited](http://search.cpan.org/perldoc?Getopt::Inherited), itself defines
the following options:

    use constant GETOPT =>
        (qw(help man logfile|log=s verbose|v+ version|V));

- `GETOPT_DEFAULTS`

This accessor, which is also accumulated across the class hierarchy, can be
used to define defaults for the options given in `GETOPT()`. For example, to
define a command-line option called <foo> which takes a string and to give it
a default, you would use:

    use constant GETOPT => qw(foo=s);
    use constant GETOPT_DEFAULTS => (foo => 'my_default');

- `opt`

This is a hash accessor per [Class::Accessor::Complex](http://search.cpan.org/perldoc?Class::Accessor::Complex) in which the option
hash is stored when it has been parsed and after default values have been
applied.

- `usage`

This method is called by `do_getopt()` after the command-line options have
been processed with [Getopt::Long](http://search.cpan.org/perldoc?Getopt::Long)'s `GetOptions`. It uses [Pod::Usage](http://search.cpan.org/perldoc?Pod::Usage) to
display help information if there was either an error during processing, or if
the `--help` or `--man` options have been given.

- `do_getopt`

Does the actual command-line processing. It accumulates the values of
L<GETOPT()> across the hierarchy, parses them, calls `usage()` if necessary,
applies L<GETOPT_DEFAULTS()>, then assigns the finished options hash to
`opt()`.

# BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests through the web interface at
<http://rt.cpan.org>.

# INSTALLATION

See perlmodinstall for information and options on installing Perl modules.

# AVAILABILITY

The latest version of this module is available from the Comprehensive Perl
Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a CPAN
site near you. Or see <http://search.cpan.org/dist/Getopt-Inherited/>.

The development version lives at <http://github.com/hanekomu/getopt-inherited/>.
Instead of sending patches, please fork this project using the standard git
and github infrastructure.

# AUTHORS

Marcel Gr&uuml;nauer, `<marcel@cpan.org>`

# COPYRIGHT AND LICENSE

Copyright 2009 by Marcel Gr&uuml;nauer

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.