NAME
GetoptLongWrapper - A wrapper for the Getopt::Long module
VERSION
Version 0.03
SYNOPSIS
A wrapper for the Getopts::Long module.
use MyMainModule; # has the definition for function the_date. In real practice, not a demo, all the support functions for the options ...
use GetoptLongWrapper; my $mmm=MyMainModule->new(); my %OPTS_CONFIG=( 'the_date' => { 'desc' => q^Print today's date.^, 'func' => 'MyModule::the_date()', 'opt_arg_eg' => '', 'opt_arg_type' => '', }, ); $ARGV[0]='--the_date'; my $golw_obj=new GetoptLongWrapper(mmm, \%OPTS_CONFIG); $golw->run_getopt(); my $rc=$golw->execute_opt(); if(ref($rc)) { use Data::Dumper; print Dumper $rc; } else { print $rc, "\n"; }
DEMO A full demo is available on GitHub. Requires a database , mySQL or MariaDB - the repository include SQL file to create and populate the database. https://github.com/ngabriel8/GOLWDemo
EXPORT
print_usage_and_die
METHODS
- new
-
my $golw = new GetoptLongWrapper($MyObj, $config_href);
The constructor takes two arguments: an object ref and a refenece to an OPTS_CONFIG hash.
print_usage_and_die Prints Usage message for the calling script and exists.
init_getopts Called by the constructor. Initializes usage, opts_array ...etc, for the GetOption call.
mk_get_opt_array Makes the array of valid options to pass to GetOption.
add_desc Makes the description part of the usage message.
run_getopt Calls the GetOptions function to populate the %opts hash.
execute_opt If %opts is not empty, executes the function associated with that option (passed from the command line).
AUTHOR
Whats his Name, <whn at theglorydays.net>
BUGS
Please report any bugs or feature requests to bug-getoptlongwrapper at rt.cpan.org
, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=GetoptLongWrapper. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc GetoptLongWrapper
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
This software is Copyright (c) 2023 by Whats his Name.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)