From: Damien Krotkine Date: Wed, 30 Mar 2011 19:38:14 +0000 (+0200) Subject: work in progress, tests are failing, and parameterized role is not flexible enough... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Getopt.git;a=commitdiff_plain;h=a9e27700692fd9cd3c6b83deb3718d199c1646d0 work in progress, tests are failing, and parameterized role is not flexible enough... May be a bad idea --- diff --git a/ChangeLog b/ChangeLog index 0aa8866..e2cf98f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ Revision history for Perl extension MooseX-Getopt +NEXT + * MooseX::Getopt + - change it to a MooseX::Role::Parameterized, so that it accepts + 'getopt_conf' parameter (Damien Krotkine) + - make it use 'pass_through' by default + 0.37 Wed 30 Mar 2011 * Fix missing dependency. (RT#67077) diff --git a/dist.ini b/dist.ini index 6899580..069e7e9 100644 --- a/dist.ini +++ b/dist.ini @@ -12,6 +12,7 @@ author = Ævar Arnfjörð Bjarmason author = Chris Prather author = Karen Etheridge author = Jonathan Swartz +author = Damien Krotkine license = Perl_5 copyright_holder = Infinity Interactive, Inc diff --git a/lib/MooseX/Getopt.pm b/lib/MooseX/Getopt.pm index 038d141..f8133ed 100644 --- a/lib/MooseX/Getopt.pm +++ b/lib/MooseX/Getopt.pm @@ -1,9 +1,21 @@ package MooseX::Getopt; # ABSTRACT: A Moose role for processing command line options -use Moose::Role 0.56; +use MooseX::Role::Parameterized; -with 'MooseX::Getopt::GLD'; +parameter getopt_conf => ( + isa => 'ArrayRef[Str]', + default => sub { [ 'pass_through' ] }, +); + +role { + + my $p = shift; + my $getopt_conf = $p->getopt_conf; + + with 'MooseX::Getopt::GLD' => { getopt_conf => $getopt_conf }; + +}; no Moose::Role; @@ -17,6 +29,10 @@ no Moose::Role; with 'MooseX::Getopt'; + # or + + with 'MooseX::Getopt' => { getopt_conf => [ 'getopt_compat', 'bundling', ... ] }; + has 'out' => (is => 'rw', isa => 'Str', required => 1); has 'in' => (is => 'rw', isa => 'Str', required => 1); @@ -76,6 +92,13 @@ Options specified in multiple places follow the following precendence order: commandline overrides configfile, which overrides explicit new_with_options parameters. +=head2 Global options + +This role is a parameterized role. It accepts a HashRef of parameters. For now +there is only one configuration parameter, C. This parameter is an +ArrayRef of strings, which are L configuraion options (see +"Configuring Getopt::Long" in L). See L for an example. + =head2 Supported Type Constraints =over 4 diff --git a/lib/MooseX/Getopt/GLD.pm b/lib/MooseX/Getopt/GLD.pm index 17567b4..fde79a8 100644 --- a/lib/MooseX/Getopt/GLD.pm +++ b/lib/MooseX/Getopt/GLD.pm @@ -112,9 +112,9 @@ role { =head1 OPTIONS -This role is a parameterized role. It accepts one configuration parameter, -C. This parameter is an ArrayRef of strings, which are -L configuraion options (see "Configuring Getopt::Long" in -L) +This role is a parameterized role. It accepts a HashRef of parameters. For now +there is only one configuration parameter, C. This parameter is an +ArrayRef of strings, which are L configuraion options (see +"Configuring Getopt::Long" in L). See L for an example. =cut diff --git a/lib/MooseX/Getopt/Strict.pm b/lib/MooseX/Getopt/Strict.pm index 8241b14..8d9d2b7 100644 --- a/lib/MooseX/Getopt/Strict.pm +++ b/lib/MooseX/Getopt/Strict.pm @@ -3,7 +3,7 @@ package MooseX::Getopt::Strict; use Moose::Role; -with 'MooseX::Getopt'; +with 'MooseX::Getopt' => { getopt_conf => [] }; around '_compute_getopt_attrs' => sub { my $next = shift; @@ -23,4 +23,7 @@ This is an stricter version of C which only processes the attributes if they explicitly set as C attributes. All other attributes are ignored by the command line handler. +Also, no L global option is activated. Especially, 'pass_through' is +not set. + =cut diff --git a/t/002_custom_option_type.t b/t/002_custom_option_type.t index 890477d..997104d 100644 --- a/t/002_custom_option_type.t +++ b/t/002_custom_option_type.t @@ -16,7 +16,7 @@ BEGIN { use Scalar::Util 'looks_like_number'; - with 'MooseX::Getopt'; + with 'MooseX::Getopt' => { getopt_conf => [] }; subtype 'ArrayOfInts' => as 'ArrayRef' diff --git a/t/004_nogetop.t b/t/004_nogetop.t index a69310f..4cc272f 100644 --- a/t/004_nogetop.t +++ b/t/004_nogetop.t @@ -14,7 +14,7 @@ BEGIN { package App; use Moose; - with 'MooseX::Getopt'; + with 'MooseX::Getopt' => { getopt_conf => [] }; has 'data' => ( metaclass => 'Getopt', diff --git a/t/007_nogetopt_trait.t b/t/007_nogetopt_trait.t index 0088983..261c8fb 100644 --- a/t/007_nogetopt_trait.t +++ b/t/007_nogetopt_trait.t @@ -14,7 +14,7 @@ BEGIN { package App; use Moose; - with 'MooseX::Getopt'; + with 'MooseX::Getopt' => { getopt_conf => [] }; has 'data' => ( traits => ['Getopt'],