The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME Wrapper::GetoptLong - A wrapper for the Getopt::Long module

VERSION Version 0.01

ABSTRACT A wrapper to the Getopt::Long module

SYNOPSIS

A wrapper for the Getopts::Long module.

use MyMainModule; # has the definition for function the_date. In real practice, not a demo, # MyMainModule defines all the support functions for the options.

use Wrapper::GetoptLong; my $mmm=MyMainModule->new(); my %OPTS_CONFIG=( 'the_date' => { 'desc' => q^Print today's date. Takes date_format as argument.^, 'func' => q^MyModule::the_date($obj->opts{'the_date'})^, 'opt_arg_eg' => '%m/%d/%Y', 'opt_arg_type' => 's', }, );

@ARGV=('--the_date', '%m/%d/%Y'); my $golw_obj=new Wrapper::GetoptLong(\%OPTS_CONFIG, $mmm); $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 includes a file to create and populate the database. https://github.com/ngabriel8/WGOLDemo

EXPORT

obj print_usage_and_die

METHODS

new
  my $golw = new Wrapper::GetoptLong($config_href, $MyObj);

The constructor takes two arguments: a reference to an OPTS_CONFIG hash and an object ref (optional).

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

Nazar Gabriel, <ngabriel@cpan.org>

BUGS

Please report any bugs or feature requests to bug-wrapper-getoptlong at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Wrapper-GetoptLong. 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 Wrapper::GetoptLong

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2023 by Nazar Gabriel.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)