27 Mar 2010 10:28:54 UTC
- Distribution: Getopt-Inherited
- Module version: 1.100860
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (1288 / 1 / 0)
- KwaliteeBus factor: 0
- 87.93% Coverage
- License: perl_5
- Perl: v5.8.0
- Download (16.71KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:1 non-PAUSE user
- BUGS AND LIMITATIONS
- COPYRIGHT AND LICENSE
Getopt::Inherited - Handling inherited command-line options
use base 'Getopt::Inherited'; use constant GETOPT => qw(foo=s); my $app = __PACKAGE__->new; $app->do_getopt;
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.
This accessor, which is accumulated across the class hierarchy using Data::Inherited, is used to define command-line options in the same format as Getopt::Long expects. This class, Getopt::Inherited, itself defines the following options:
use constant GETOPT => (qw(help man logfile|log=s verbose|v+ version|V));
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');
This is a hash accessor per Class::Accessor::Complex in which the option hash is stored when it has been parsed and after default values have been applied.
This method is called by
do_getopt()after the command-line options have been processed with Getopt::Long's
GetOptions. It uses Pod::Usage to display help information if there was either an error during processing, or if the
--manoptions have been given.
Does the actual command-line processing. It accumulates the values of GETOPT() across the hierarchy, parses them, calls
usage()if necessary, applies GETOPT_DEFAULTS(), then assigns the finished options hash to
See perlmodinstall for information and options on installing Perl modules.
No bugs have been reported.
Please report any bugs or feature requests through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=Getopt-Inherited.
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.
Marcel Gruenauer <email@example.com>
This software is copyright (c) 2010 by Marcel Gruenauer.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install Getopt::Inherited, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Getopt::Inherited
For more information on module installation, please visit the detailed CPAN module installation guide.
|s||Focus search bar|
|?||Bring up this help dialog|
|g p||Go to pull requests|
|g i||go to github issues (only if github is preferred repository)|
|g a||Go to author|
|g c||Go to changes|
|g i||Go to issues|
|g d||Go to dist|
|g r||Go to repository/SCM|
|g s||Go to source|
|g b||Go to file browse|