- refactored &new_with_option some so that
this will work better with other Getopt
modules (nuffin)
+
+ + MooseX::Getopt::Strict
+ - version of MooseX::Getopt which requires
+ you to specify which attributes you want
+ processed explicity
+ - added tests for this
+
+ + MooseX::Getopt::Meta::Attribute::NoGetopt
+ - a custom meta-attribute which can be
+ used to specify that an attribute should
+ not be processed
+ - added tests for this
0.05 Tues. July 3, 2007
* MooseX::Getopt::OptionTypeMap
README
lib/MooseX/Getopt.pm
lib/MooseX/Getopt/OptionTypeMap.pm
+lib/MooseX/Getopt/Strict.pm
lib/MooseX/Getopt/Meta/Attribute.pm
+lib/MooseX/Getopt/Meta/Attribute/NoGetopt.pm
t/000_load.t
t/001_basic.t
t/002_custom_option_type.t
t/003_inferred_option_type.t
+t/004_nogetop.t
+t/005_strict.t
t/pod.t
t/pod_coverage.t
use MooseX::Getopt::OptionTypeMap;
use MooseX::Getopt::Meta::Attribute;
+use MooseX::Getopt::Meta::Attribute::NoGetopt;
our $VERSION = '0.06';
our $AUTHORITY = 'cpan:STEVAN';
sub _compute_getopt_attrs {
my $class = shift;
-
grep {
$_->isa("MooseX::Getopt::Meta::Attribute")
or
$_->name !~ /^_/
&&
- !$_->isa('MooseX::Getopt::Meta::NoGetopt')
+ !$_->isa('MooseX::Getopt::Meta::Attribute::NoGetopt')
} $class->meta->compute_all_applicable_attributes
}
You can use the attribute metaclass L<MooseX::Getopt::Meta::Attribute>
to get non-default commandline option names and aliases.
+You can use the attribute metaclass L<MooseX::Getopt::Meta::Attribute::NoGetOpt>
+to have C<MooseX::Getopt> ignore your attribute in the commandline options.
+
By default, attributes which start with an underscore are not given
commandline argument support, unless the attribute's metaclass is set
to L<MooseX::Getopt::Meta::Attribute>. If you don't want you accessors
-package MooseX::Getopt::Meta::NoGetopt;
+package MooseX::Getopt::Meta::Attribute::NoGetopt;
use Moose;
-use Moose::Util::TypeConstraints;
our $VERSION = '0.01';
our $AUTHORITY = 'cpan:STEVAN';
# register this as a metaclass alias ...
package Moose::Meta::Attribute::Custom::NoGetopt;
-sub register_implementation { 'MooseX::Getopt::Meta::NoGetopt' }
+sub register_implementation { 'MooseX::Getopt::Meta::Attribute::NoGetopt' }
1;
=head1 NAME
-MooseX::NoGetopt::Meta::Attribute - Optional meta attribute for custom option names
+MooseX::Getopt::Meta::Attribute::NoGetOpt - Optional meta attribute for ignoring params
=head1 SYNOPSIS
with 'MooseX::Getopt';
-sub _compute_getopt_attrs {
+around '_compute_getopt_attrs' => sub {
+ my $next = shift;
my ( $class, @args ) = @_;
grep {
$_->isa("MooseX::Getopt::Meta::Attribute")
- } $class->MooseX::Getopt::_compute_getopt_attrs(@args);
-}
+ } $class->$next(@args);
+};
-__PACKAGE__;
+1;
__END__
=head1 NAME
MooseX::Getopt::Strict - only make options for attrs with the Getopt metaclass
+
+=head1 DESCRIPTION
-=head1 SYNOPSIS
-
- # see MooseX::Getopt
+This is an stricter version of C<MooseX::Getopt> which only processes the
+attributes if they explicitly set as C<Getopt> attributes. All other attributes
+are ignored by the command line handler.
+
+=head1 METHODS
=over 4
=item meta
-Is a section devoted to making the #!#%^ stupid pod coverage test pass. Stevan, I do
-hope you're actually reading this.
+=back
-Love,
-Yuval
+=head1 BUGS
-=back
+All complex software has bugs lurking in it, and this module is no
+exception. If you find a bug please either email me, or add the bug
+to cpan-RT.
+
+=head1 AUTHOR
+
+Stevan Little E<lt>stevan@iinteractive.comE<gt>
+
+Yuval Kogman C<< <nuffin@cpan.org> >>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2007 by Infinity Interactive, Inc.
+
+L<http://www.iinteractive.com>
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
=cut
}
{
-
package App;
use Moose;
with 'MooseX::Getopt';
has 'data' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ metaclass => 'Getopt',
is => 'ro',
isa => 'Str',
default => 'file.dat',
);
has 'horse' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ metaclass => 'Getopt',
is => 'ro',
isa => 'Str',
default => 'bray',
);
has 'private_stuff' => (
- metaclass => 'MooseX::Getopt::Meta::NoGetopt',
+ metaclass => 'NoGetopt',
is => 'ro',
isa => 'Int',
default => 713
);
has '_private_stuff_cmdline' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ metaclass => 'Getopt',
is => 'ro',
isa => 'Int',
default => 832,
with 'MooseX::Getopt::Strict';
has 'data' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ metaclass => 'Getopt',
is => 'ro',
isa => 'Str',
default => 'file.dat',
);
has 'horse' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ metaclass => 'Getopt',
is => 'ro',
isa => 'Str',
default => 'bray',