Programming:Perl:MooX::Options

From Knowledge base
Jump to: navigation, search

MooX::Options is a module to quickly create command line tools using your favorite object maker system. It works with Mo, Moo, Mouse, Moose and any object maker.

Example:

{
package MyCmdLineTools;
use Moo;
use MooX::Options;

option 'verbose' => (
 is => 'ro',
 repeatable => 1,
 doc => 'be more verbose on the program',
);

option 'id' => (
 is => 'ro',
 format => 'i',
 repeatable => 1,
 autosplit => ',',
 doc => 'list of id',
 default => sub {[]},
);

1;
}

use 5.010;
my $opt = MyCmdLineTools->new_with_options;
if ($opt->verbose) {
    say "ID: $_" for @{$opt->id};
}

The coverage is now :

---------------------------- ------ ------ ------ ------ ------ ------ ------
File                           stmt   bran   cond    sub    pod   time  total
---------------------------- ------ ------ ------ ------ ------ ------ ------
blib/lib/MooX/Options.pm      100.0  100.0  100.0  100.0    n/a   76.3  100.0
.../lib/MooX/Options/Role.pm  100.0  100.0  100.0  100.0  100.0   23.7  100.0
Total                         100.0  100.0  100.0  100.0  100.0  100.0  100.0
---------------------------- ------ ------ ------ ------ ------ ------ ------

Here some links :

If you have some issues with it, thanks to report on GitHub or CPAN, or here.



Share your opinion