Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Import from MooseX::Getopt 0.31

  • Loading branch information...
commit fe516759c77302dab87756baa9bd76d5b18b6023 1 parent ff05e3f
FUJI Goro (gfx) authored
Showing with 238 additions and 229 deletions.
  1. +1 −1  .gitignore
  2. +7 −1 ChangeLog
  3. +9 −6 dist.ini
  4. +17 −17 lib/{MooseX → MouseX}/Getopt.pm
  5. +17 −17 lib/{MooseX → MouseX}/Getopt/Basic.pm
  6. +10 −10 lib/{MooseX → MouseX}/Getopt/Dashes.pm
  7. +8 −8 lib/{MooseX → MouseX}/Getopt/GLD.pm
  8. +14 −14 lib/{MooseX → MouseX}/Getopt/Meta/Attribute.pm
  9. +10 −10 lib/{MooseX → MouseX}/Getopt/Meta/Attribute/NoGetopt.pm
  10. +15 −15 lib/{MooseX → MouseX}/Getopt/Meta/Attribute/Trait.pm
  11. +8 −8 lib/{MooseX → MouseX}/Getopt/Meta/Attribute/Trait/NoGetopt.pm
  12. +6 −6 lib/{MooseX → MouseX}/Getopt/OptionTypeMap.pm
  13. +6 −6 lib/{MooseX → MouseX}/Getopt/Strict.pm
  14. +1 −1  t/000_load.t
  15. +8 −8 t/001_basic.t
  16. +5 −5 t/002_custom_option_type.t
  17. +4 −4 t/003_inferred_option_type.t
  18. +3 −3 t/004_nogetop.t
  19. +3 −3 t/005_strict.t
  20. +7 −7 t/006_metaclass_traits.t
  21. +3 −3 t/007_nogetopt_trait.t
  22. +11 −11 t/008_configfromfile.t
  23. +3 −3 t/009_gld_and_explicit_options.t
  24. +3 −3 t/010_dashes.t
  25. +3 −3 t/100_gld_default_bug.t
  26. +4 −4 t/101_argv_bug.t
  27. +8 −8 t/102_basic_basic.t
  28. +2 −2 t/103_uc_bug.t
  29. +2 −2 t/104_override_usage.t
  30. +8 −8 t/105_uc_bug_more.t
  31. +8 −8 t/106_no_ignore_case.t
  32. +7 −7 t/107_no_auto_help.t
  33. +6 −6 t/108_usage_attr.t
  34. +2 −2 t/109_help_flag.t
  35. +9 −9 t/110_sort_usage_by_attr_order.t
2  .gitignore
View
@@ -1,4 +1,4 @@
-MooseX-Getopt-*
+MouseX-Getopt-*
pm_to_blib
inc
blib
8 ChangeLog
View
@@ -1,4 +1,10 @@
-Revision history for Perl extension MooseX-Getopt
+Revision history for Perl extension MouseX-Getopt
+
+0.31 Mon Jul 26 20:52:38 2010
+ * Just copied from MooseX-Getopt 0.31
+
+NOTE: This distribution is a copy of MooseX-Getopt, so the following history
+ is that of MooseX-Getopt's, not MouseX-Geopt's.
0.31 Wed 7 Jul 2010
* Fix issue causing tests to fail if MooseX::SimpleConfig isn't installed.
15 dist.ini
View
@@ -1,5 +1,7 @@
-name = MooseX-Getopt
+name = MouseX-Getopt
version = 0.31
+author = NAKAGAWA Masaki <masaki@cpan.org>
+author = FUJI Goro <gfuji@cpan.org>
author = Stevan Little <stevan@iinteractive.com>
author = Brandon L. Black <blblack@gmail.com>
author = Yuval Kogman <nothingmuch@woobling.org>
@@ -7,22 +9,23 @@ author = Ryan D Johnson <ryan@innerfence.com>
author = Drew Taylor <drew@drewtaylor.com>
author = Tomas Doran <bobtfish@bobtfish.net>
author = Florian Ragwitz <rafl@debian.org>
-author = Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
-author = Ævar Arnfjörð Bjarmason <avar@cpan.org>
+author = Dagfinn Ilmari Mannsaker <ilmari@ilmari.org>
+author = Avar Arnfjord Bjarmason <avar@cpan.org>
author = Chris Prather <perigrin@cpan.org>
license = Perl_5
copyright_holder = Infinity Interactive, Inc
[@FLORA]
-dist = MooseX-Getopt
-repository_at = gitmo
+dist = MouseX-Getopt
+repository_at = github
+github_user = gfx
authority = cpan:STEVAN
auto_prereq = 0
[Prereq]
Getopt::Long = 2.37
Getopt::Long::Descriptive = 0.081
-Moose = 0.56
+Mouse = 0.64
[Prereq / TestRequires]
Test::Exception = 0.21
34 lib/MooseX/Getopt.pm → lib/MouseX/Getopt.pm
View
@@ -1,11 +1,11 @@
-package MooseX::Getopt;
-# ABSTRACT: A Moose role for processing command line options
+package MouseX::Getopt;
+# ABSTRACT: A Mouse role for processing command line options
-use Moose::Role 0.56;
+use Mouse::Role;
-with 'MooseX::Getopt::GLD';
+with 'MouseX::Getopt::GLD';
-no Moose::Role;
+no Mouse::Role;
1;
@@ -13,9 +13,9 @@ no Moose::Role;
## In your class
package My::App;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt';
+ with 'MouseX::Getopt';
has 'out' => (is => 'rw', isa => 'Str', required => 1);
has 'in' => (is => 'rw', isa => 'Str', required => 1);
@@ -44,17 +44,17 @@ of your attribute as the command line option, and if there is a type
constraint defined, it will configure Getopt::Long to handle the option
accordingly.
-You can use the trait L<MooseX::Getopt::Meta::Attribute::Trait> or the
-attribute metaclass L<MooseX::Getopt::Meta::Attribute> to get non-default
+You can use the trait L<MouseX::Getopt::Meta::Attribute::Trait> or the
+attribute metaclass L<MouseX::Getopt::Meta::Attribute> to get non-default
commandline option names and aliases.
-You can use the trait L<MooseX::Getopt::Meta::Attribute::Trait::NoGetopt>
-or the attribute metaclass L<MooseX::Getopt::Meta::Attribute::NoGetopt>
-to have C<MooseX::Getopt> ignore your attribute in the commandline options.
+You can use the trait L<MouseX::Getopt::Meta::Attribute::Trait::NoGetopt>
+or the attribute metaclass L<MouseX::Getopt::Meta::Attribute::NoGetopt>
+to have C<MouseX::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 your accessors
+to L<MouseX::Getopt::Meta::Attribute>. If you don't want your accessors
to have the leading underscore in their name, you can do this:
# for read/write attributes
@@ -67,8 +67,8 @@ This will mean that Getopt will not handle a --foo param, but your
code can still call the C<foo> method.
If your class also uses a configfile-loading role based on
-L<MooseX::ConfigFromFile>, such as L<MooseX::SimpleConfig>,
-L<MooseX::Getopt>'s C<new_with_options> will load the configfile
+L<MouseX::ConfigFromFile>, such as L<MouseX::SimpleConfig>,
+L<MouseX::Getopt>'s C<new_with_options> will load the configfile
specified by the C<--configfile> option (or the default you've
given for the configfile attribute) for you.
@@ -145,7 +145,7 @@ so:
Then you register the mapping, like so:
- MooseX::Getopt::OptionTypeMap->add_option_type_to_map(
+ MouseX::Getopt::OptionTypeMap->add_option_type_to_map(
'ArrayOfInts' => '=i@'
);
@@ -173,7 +173,7 @@ Better examples are certainly welcome :)
If you define a custom subtype which is a subtype of one of the
standard L</Supported Type Constraints> above, and do not explicitly
provide custom support as in L</Custom Type Constraints> above,
-MooseX::Getopt will treat it like the parent type for Getopt
+MouseX::Getopt will treat it like the parent type for Getopt
purposes.
For example, if you had the same custom C<ArrayOfInts> subtype
34 lib/MooseX/Getopt/Basic.pm → lib/MouseX/Getopt/Basic.pm
View
@@ -1,11 +1,11 @@
-package MooseX::Getopt::Basic;
-# ABSTRACT: MooseX::Getopt::Basic - role to implement the Getopt::Long functionality
+package MouseX::Getopt::Basic;
+# ABSTRACT: MouseX::Getopt::Basic - role to implement the Getopt::Long functionality
-use Moose::Role;
+use Mouse::Role;
-use MooseX::Getopt::OptionTypeMap;
-use MooseX::Getopt::Meta::Attribute;
-use MooseX::Getopt::Meta::Attribute::NoGetopt;
+use MouseX::Getopt::OptionTypeMap;
+use MouseX::Getopt::Meta::Attribute;
+use MouseX::Getopt::Meta::Attribute::NoGetopt;
use Carp ();
use Getopt::Long 2.37 ();
@@ -17,7 +17,7 @@ sub new_with_options {
my ($class, @params) = @_;
my $config_from_file;
- if($class->meta->does_role('MooseX::ConfigFromFile')) {
+ if($class->meta->does_role('MouseX::ConfigFromFile')) {
local @ARGV = @ARGV;
# just get the configfile arg now; the rest of the args will be
@@ -160,11 +160,11 @@ sub _compute_getopt_attrs {
my $class = shift;
sort { $a->insertion_order <=> $b->insertion_order }
grep {
- $_->does("MooseX::Getopt::Meta::Attribute::Trait")
+ $_->does("MouseX::Getopt::Meta::Attribute::Trait")
or
$_->name !~ /^_/
} grep {
- !$_->does('MooseX::Getopt::Meta::Attribute::Trait::NoGetopt')
+ !$_->does('MouseX::Getopt::Meta::Attribute::Trait::NoGetopt')
} $class->meta->get_all_attributes
}
@@ -175,7 +175,7 @@ sub _get_cmd_flags_for_attr {
my @aliases;
- if ($attr->does('MooseX::Getopt::Meta::Attribute::Trait')) {
+ if ($attr->does('MouseX::Getopt::Meta::Attribute::Trait')) {
$flag = $attr->cmd_flag if $attr->has_cmd_flag;
@aliases = @{ $attr->cmd_aliases } if $attr->has_cmd_aliases;
}
@@ -199,8 +199,8 @@ sub _attrs_to_options {
}
elsif ($attr->has_type_constraint) {
my $type = $attr->type_constraint;
- if (MooseX::Getopt::OptionTypeMap->has_option_type($type)) {
- $opt_string .= MooseX::Getopt::OptionTypeMap->get_option_type($type)
+ if (MouseX::Getopt::OptionTypeMap->has_option_type($type)) {
+ $opt_string .= MouseX::Getopt::OptionTypeMap->get_option_type($type)
}
}
@@ -225,16 +225,16 @@ sub _attrs_to_options {
return @options;
}
-no Moose::Role;
+no Mouse::Role;
1;
=head1 SYNOPSIS
## In your class
package My::App;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt::Basic';
+ with 'MouseX::Getopt::Basic';
has 'out' => (is => 'rw', isa => 'Str', required => 1);
has 'in' => (is => 'rw', isa => 'Str', required => 1);
@@ -254,11 +254,11 @@ no Moose::Role;
=head1 DESCRIPTION
-This is like L<MooseX::Getopt> and can be used instead except that it
+This is like L<MouseX::Getopt> and can be used instead except that it
doesn't make use of L<Getopt::Long::Descriptive> (or "GLD" for short).
=method new_with_options
-See L<MooseX::Getopt/new_with_options>.
+See L<MouseX::Getopt/new_with_options>.
=cut
20 lib/MooseX/Getopt/Dashes.pm → lib/MouseX/Getopt/Dashes.pm
View
@@ -1,9 +1,9 @@
-package MooseX::Getopt::Dashes;
+package MouseX::Getopt::Dashes;
# ABSTRACT: convert underscores in attribute names to dashes
-use Moose::Role;
+use Mouse::Role;
-with 'MooseX::Getopt';
+with 'MouseX::Getopt';
around _get_cmd_flags_for_attr => sub {
my $next = shift;
@@ -11,21 +11,21 @@ around _get_cmd_flags_for_attr => sub {
my ( $flag, @aliases ) = $class->$next($attr, @rest);
$flag =~ tr/_/-/
- unless $attr->does('MooseX::Getopt::Meta::Attribute::Trait')
+ unless $attr->does('MouseX::Getopt::Meta::Attribute::Trait')
&& $attr->has_cmd_flag;
return ( $flag, @aliases );
};
-no Moose::Role;
+no Mouse::Role;
1;
=head1 SYNOPSIS
package My::App;
- use Moose;
- with 'MooseX::Getopt::Dashes';
+ use Mouse;
+ with 'MouseX::Getopt::Dashes';
# Will be called as --some-thingy, not --some_thingy
has 'some_thingy' => (
@@ -43,15 +43,15 @@ no Moose::Role;
default => 'foo'
);
- # use as MooseX::Getopt
+ # use as MouseX::Getopt
=head1 DESCRIPTION
-This is a version of C<MooseX::Getopt> which converts underscores in
+This is a version of C<MouseX::Getopt> which converts underscores in
attribute names to dashes when generating command line flags.
You can selectively disable this on a per-attribute basis by supplying
-a L<cmd_flag|MooseX::Getopt::Meta::Attribute/METHODS> argument with
+a L<cmd_flag|MouseX::Getopt::Meta::Attribute/METHODS> argument with
the command flag you'd like for a given attribute. No underscore to
dash replacement will be done on the C<cmd_flag>.
16 lib/MooseX/Getopt/GLD.pm → lib/MouseX/Getopt/GLD.pm
View
@@ -1,11 +1,11 @@
-package MooseX::Getopt::GLD;
-# ABSTRACT: A Moose role for processing command line options with Getopt::Long::Descriptive
+package MouseX::Getopt::GLD;
+# ABSTRACT: A Mouse role for processing command line options with Getopt::Long::Descriptive
-use Moose::Role;
+use Mouse::Role;
use Getopt::Long::Descriptive 0.081;
-with 'MooseX::Getopt::Basic';
+with 'MouseX::Getopt::Basic';
has usage => (
is => 'rw', isa => 'Getopt::Long::Descriptive::Usage',
@@ -48,7 +48,7 @@ sub _gld_spec {
# NOTE:
# remove this 'feature' because it didn't work
# all the time, and so is better to not bother
- # since Moose will handle the defaults just
+ # since Mouse will handle the defaults just
# fine anyway.
# - SL
#( exists $opt->{default} ? (default => $opt->{default}) : () ),
@@ -64,7 +64,7 @@ sub _gld_spec {
return ( \@options, \%name_to_init_arg );
}
-no Moose::Role;
+no Mouse::Role;
1;
@@ -72,9 +72,9 @@ no Moose::Role;
## In your class
package My::App;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt::GLD';
+ with 'MouseX::Getopt::GLD';
has 'out' => (is => 'rw', isa => 'Str', required => 1);
has 'in' => (is => 'rw', isa => 'Str', required => 1);
28 lib/MooseX/Getopt/Meta/Attribute.pm → lib/MouseX/Getopt/Meta/Attribute.pm
View
@@ -1,40 +1,40 @@
-package MooseX::Getopt::Meta::Attribute;
+package MouseX::Getopt::Meta::Attribute;
# ABSTRACT: Optional meta attribute for custom option names
-use Moose;
-use Moose::Util::TypeConstraints;
+use Mouse;
+use Mouse::Util::TypeConstraints;
-extends 'Moose::Meta::Attribute'; # << Moose extending Moose :)
- with 'MooseX::Getopt::Meta::Attribute::Trait';
+extends 'Mouse::Meta::Attribute'; # << Mouse extending Mouse :)
+ with 'MouseX::Getopt::Meta::Attribute::Trait';
-no Moose;
+no Mouse;
# register this as a metaclass alias ...
package # stop confusing PAUSE
- Moose::Meta::Attribute::Custom::Getopt;
-sub register_implementation { 'MooseX::Getopt::Meta::Attribute' }
+ Mouse::Meta::Attribute::Custom::Getopt;
+sub register_implementation { 'MouseX::Getopt::Meta::Attribute' }
1;
=head1 SYNOPSIS
package App;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt';
+ with 'MouseX::Getopt';
has 'data' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ metaclass => 'MouseX::Getopt::Meta::Attribute',
is => 'ro',
isa => 'Str',
default => 'file.dat',
- # tells MooseX::Getopt to use --somedata as the
+ # tells MouseX::Getopt to use --somedata as the
# command line flag instead of the normal
# autogenerated one (--data)
cmd_flag => 'somedata',
- # tells MooseX::Getopt to also allow --moosedata,
+ # tells MouseX::Getopt to also allow --moosedata,
# -m, and -d as aliases for this same option on
# the commandline.
cmd_aliases => [qw/ moosedata m d /],
@@ -47,7 +47,7 @@ sub register_implementation { 'MooseX::Getopt::Meta::Attribute' }
This is a custom attribute metaclass which can be used to specify a
the specific command line flag to use instead of the default one
-which L<MooseX::Getopt> will create for you.
+which L<MouseX::Getopt> will create for you.
This is certainly not the prettiest way to go about this, but for
now it works for those who might need such a feature.
20 lib/MooseX/Getopt/Meta/Attribute/NoGetopt.pm → lib/MouseX/Getopt/Meta/Attribute/NoGetopt.pm
View
@@ -1,26 +1,26 @@
-package MooseX::Getopt::Meta::Attribute::NoGetopt;
+package MouseX::Getopt::Meta::Attribute::NoGetopt;
# ABSTRACT: Optional meta attribute for ignoring params
-use Moose;
+use Mouse;
-extends 'Moose::Meta::Attribute'; # << Moose extending Moose :)
- with 'MooseX::Getopt::Meta::Attribute::Trait::NoGetopt';
+extends 'Mouse::Meta::Attribute'; # << Mouse extending Mouse :)
+ with 'MouseX::Getopt::Meta::Attribute::Trait::NoGetopt';
-no Moose;
+no Mouse;
# register this as a metaclass alias ...
package # stop confusing PAUSE
- Moose::Meta::Attribute::Custom::NoGetopt;
-sub register_implementation { 'MooseX::Getopt::Meta::Attribute::NoGetopt' }
+ Mouse::Meta::Attribute::Custom::NoGetopt;
+sub register_implementation { 'MouseX::Getopt::Meta::Attribute::NoGetopt' }
1;
=head1 SYNOPSIS
package App;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt';
+ with 'MouseX::Getopt';
has 'data' => (
metaclass => 'NoGetopt', # do not attempt to capture this param
@@ -33,7 +33,7 @@ sub register_implementation { 'MooseX::Getopt::Meta::Attribute::NoGetopt' }
This is a custom attribute metaclass which can be used to specify
that a specific attribute should B<not> be processed by
-C<MooseX::Getopt>. All you need to do is specify the C<NoGetopt>
+C<MouseX::Getopt>. All you need to do is specify the C<NoGetopt>
metaclass.
has 'foo' => (metaclass => 'NoGetopt', ... );
30 lib/MooseX/Getopt/Meta/Attribute/Trait.pm → lib/MouseX/Getopt/Meta/Attribute/Trait.pm
View
@@ -1,8 +1,8 @@
-package MooseX::Getopt::Meta::Attribute::Trait;
+package MouseX::Getopt::Meta::Attribute::Trait;
# ABSTRACT: Optional meta attribute trait for custom option names
-use Moose::Role;
-use Moose::Util::TypeConstraints;
+use Mouse::Role;
+use Mouse::Util::TypeConstraints;
has 'cmd_flag' => (
is => 'rw',
@@ -12,35 +12,35 @@ has 'cmd_flag' => (
# This subtype is to support scalar -> arrayref coercion
# without polluting the built-in types
-subtype '_MooseX_Getopt_CmdAliases' => as 'ArrayRef';
+subtype '_MouseX_Getopt_CmdAliases' => as 'ArrayRef';
-coerce '_MooseX_Getopt_CmdAliases'
+coerce '_MouseX_Getopt_CmdAliases'
=> from 'Str'
=> via { [$_] };
has 'cmd_aliases' => (
is => 'rw',
- isa => '_MooseX_Getopt_CmdAliases',
+ isa => '_MouseX_Getopt_CmdAliases',
predicate => 'has_cmd_aliases',
coerce => 1,
);
-no Moose::Util::TypeConstraints;
-no Moose::Role;
+no Mouse::Util::TypeConstraints;
+no Mouse::Role;
# register this as a metaclass alias ...
package # stop confusing PAUSE
- Moose::Meta::Attribute::Custom::Trait::Getopt;
-sub register_implementation { 'MooseX::Getopt::Meta::Attribute::Trait' }
+ Mouse::Meta::Attribute::Custom::Trait::Getopt;
+sub register_implementation { 'MouseX::Getopt::Meta::Attribute::Trait' }
1;
=head1 SYNOPSIS
package App;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt';
+ with 'MouseX::Getopt';
has 'data' => (
traits => [ 'Getopt' ],
@@ -48,12 +48,12 @@ sub register_implementation { 'MooseX::Getopt::Meta::Attribute::Trait' }
isa => 'Str',
default => 'file.dat',
- # tells MooseX::Getopt to use --somedata as the
+ # tells MouseX::Getopt to use --somedata as the
# command line flag instead of the normal
# autogenerated one (--data)
cmd_flag => 'somedata',
- # tells MooseX::Getopt to also allow --moosedata,
+ # tells MouseX::Getopt to also allow --moosedata,
# -m, and -d as aliases for this same option on
# the commandline.
cmd_aliases => [qw/ moosedata m d /],
@@ -66,7 +66,7 @@ sub register_implementation { 'MooseX::Getopt::Meta::Attribute::Trait' }
This is a custom attribute metaclass trait which can be used to
specify a the specific command line flag to use instead of the
-default one which L<MooseX::Getopt> will create for you.
+default one which L<MouseX::Getopt> will create for you.
=method B<cmd_flag>
16 lib/MooseX/Getopt/Meta/Attribute/Trait/NoGetopt.pm → lib/MouseX/Getopt/Meta/Attribute/Trait/NoGetopt.pm
View
@@ -1,22 +1,22 @@
-package MooseX::Getopt::Meta::Attribute::Trait::NoGetopt;
+package MouseX::Getopt::Meta::Attribute::Trait::NoGetopt;
# ABSTRACT: Optional meta attribute trait for ignoring params
-use Moose::Role;
-no Moose::Role;
+use Mouse::Role;
+no Mouse::Role;
# register this as a metaclass alias ...
package # stop confusing PAUSE
- Moose::Meta::Attribute::Custom::Trait::NoGetopt;
-sub register_implementation { 'MooseX::Getopt::Meta::Attribute::Trait::NoGetopt' }
+ Mouse::Meta::Attribute::Custom::Trait::NoGetopt;
+sub register_implementation { 'MouseX::Getopt::Meta::Attribute::Trait::NoGetopt' }
1;
=head1 SYNOPSIS
package App;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt';
+ with 'MouseX::Getopt';
has 'data' => (
traits => [ 'NoGetopt' ], # do not attempt to capture this param
@@ -29,7 +29,7 @@ sub register_implementation { 'MooseX::Getopt::Meta::Attribute::Trait::NoGetopt'
This is a custom attribute metaclass trait which can be used to
specify that a specific attribute should B<not> be processed by
-C<MooseX::Getopt>. All you need to do is specify the C<NoGetopt>
+C<MouseX::Getopt>. All you need to do is specify the C<NoGetopt>
metaclass trait.
has 'foo' => (traits => [ 'NoGetopt', ... ], ... );
12 lib/MooseX/Getopt/OptionTypeMap.pm → lib/MouseX/Getopt/OptionTypeMap.pm
View
@@ -1,8 +1,8 @@
-package MooseX::Getopt::OptionTypeMap;
+package MouseX::Getopt::OptionTypeMap;
# ABSTRACT: Storage for the option to type mappings
-use Moose 'confess', 'blessed';
-use Moose::Util::TypeConstraints 'find_type_constraint';
+use Mouse 'confess', 'blessed';
+use Mouse::Util::TypeConstraints 'find_type_constraint';
my %option_type_map = (
'Bool' => '!',
@@ -66,14 +66,14 @@ sub add_option_type_to_map {
$option_type_map{$type_name} = $option_string;
}
-no Moose::Util::TypeConstraints;
-no Moose;
+no Mouse::Util::TypeConstraints;
+no Mouse;
1;
=head1 DESCRIPTION
-See the I<Custom Type Constraints> section in the L<MooseX::Getopt> docs
+See the I<Custom Type Constraints> section in the L<MouseX::Getopt> docs
for more info about how to use this module.
=method B<has_option_type ($type_or_name)>
12 lib/MooseX/Getopt/Strict.pm → lib/MouseX/Getopt/Strict.pm
View
@@ -1,25 +1,25 @@
-package MooseX::Getopt::Strict;
+package MouseX::Getopt::Strict;
# ABSTRACT: only make options for attrs with the Getopt metaclass
-use Moose::Role;
+use Mouse::Role;
-with 'MooseX::Getopt';
+with 'MouseX::Getopt';
around '_compute_getopt_attrs' => sub {
my $next = shift;
my ( $class, @args ) = @_;
grep {
- $_->does("MooseX::Getopt::Meta::Attribute::Trait")
+ $_->does("MouseX::Getopt::Meta::Attribute::Trait")
} $class->$next(@args);
};
-no Moose::Role;
+no Mouse::Role;
1;
=head1 DESCRIPTION
-This is an stricter version of C<MooseX::Getopt> which only processes the
+This is an stricter version of C<MouseX::Getopt> which only processes the
attributes if they explicitly set as C<Getopt> attributes. All other attributes
are ignored by the command line handler.
2  t/000_load.t
View
@@ -6,5 +6,5 @@ use warnings;
use Test::More tests => 1;
BEGIN {
- use_ok('MooseX::Getopt');
+ use_ok('MouseX::Getopt');
}
16 t/001_basic.t
View
@@ -6,17 +6,17 @@ use warnings;
use Test::More tests => 69;
BEGIN {
- use_ok('MooseX::Getopt');
+ use_ok('MouseX::Getopt');
}
{
package App;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt';
+ with 'MouseX::Getopt';
has 'data' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ metaclass => 'MouseX::Getopt::Meta::Attribute',
is => 'ro',
isa => 'Str',
default => 'file.dat',
@@ -32,7 +32,7 @@ BEGIN {
);
has 'horse' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ metaclass => 'MouseX::Getopt::Meta::Attribute',
is => 'ro',
isa => 'Str',
default => 'bray',
@@ -70,7 +70,7 @@ BEGIN {
);
has '_private_stuff_cmdline' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ metaclass => 'MouseX::Getopt::Meta::Attribute',
is => 'ro',
isa => 'Int',
default => 832,
@@ -81,8 +81,8 @@ BEGIN {
foreach my $attr_name (qw(data cow horse _private_stuff_cmdline)) {
my $attr = App->meta->get_attribute($attr_name);
- isa_ok($attr, 'Moose::Meta::Attribute');
- isa_ok($attr, 'MooseX::Getopt::Meta::Attribute');
+ isa_ok($attr, 'Mouse::Meta::Attribute');
+ isa_ok($attr, 'MouseX::Getopt::Meta::Attribute');
can_ok($attr, 'cmd_flag');
can_ok($attr, 'cmd_aliases');
}
10 t/002_custom_option_type.t
View
@@ -6,23 +6,23 @@ use warnings;
use Test::More tests => 6;
BEGIN {
- use_ok('MooseX::Getopt');
+ use_ok('MouseX::Getopt');
}
{
package App;
- use Moose;
- use Moose::Util::TypeConstraints;
+ use Mouse;
+ use Mouse::Util::TypeConstraints;
use Scalar::Util 'looks_like_number';
- with 'MooseX::Getopt';
+ with 'MouseX::Getopt';
subtype 'ArrayOfInts'
=> as 'ArrayRef'
=> where { scalar (grep { looks_like_number($_) } @$_) };
- MooseX::Getopt::OptionTypeMap->add_option_type_to_map(
+ MouseX::Getopt::OptionTypeMap->add_option_type_to_map(
'ArrayOfInts' => '=i@'
);
8 t/003_inferred_option_type.t
View
@@ -6,17 +6,17 @@ use warnings;
use Test::More tests => 5;
BEGIN {
- use_ok('MooseX::Getopt');
+ use_ok('MouseX::Getopt');
}
{
package App;
- use Moose;
- use Moose::Util::TypeConstraints;
+ use Mouse;
+ use Mouse::Util::TypeConstraints;
use Scalar::Util 'looks_like_number';
- with 'MooseX::Getopt';
+ with 'MouseX::Getopt';
subtype 'ArrayOfInts'
=> as 'ArrayRef'
6 t/004_nogetop.t
View
@@ -7,14 +7,14 @@ use Test::More tests => 9;
use Test::Exception;
BEGIN {
- use_ok('MooseX::Getopt');
+ use_ok('MouseX::Getopt');
}
{
package App;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt';
+ with 'MouseX::Getopt';
has 'data' => (
metaclass => 'Getopt',
6 t/005_strict.t
View
@@ -7,15 +7,15 @@ use Test::More tests => 10;
use Test::Exception;
BEGIN {
- use_ok('MooseX::Getopt');
+ use_ok('MouseX::Getopt');
}
{
package App;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt::Strict';
+ with 'MouseX::Getopt::Strict';
has 'data' => (
metaclass => 'Getopt',
14 t/006_metaclass_traits.t
View
@@ -4,20 +4,20 @@ use strict;
use warnings;
use Test::More tests => 69;
-use Test::Moose;
+use Test::Mouse;
BEGIN {
- use_ok('MooseX::Getopt');
+ use_ok('MouseX::Getopt');
}
{
package App;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt';
+ with 'MouseX::Getopt';
has 'data' => (
- traits => [ 'MooseX::Getopt::Meta::Attribute::Trait' ],
+ traits => [ 'MouseX::Getopt::Meta::Attribute::Trait' ],
is => 'ro',
isa => 'Str',
default => 'file.dat',
@@ -82,8 +82,8 @@ BEGIN {
foreach my $attr_name (qw(data cow horse _private_stuff_cmdline)) {
my $attr = App->meta->get_attribute($attr_name);
- isa_ok($attr, 'Moose::Meta::Attribute');
- does_ok($attr, 'MooseX::Getopt::Meta::Attribute::Trait');
+ isa_ok($attr, 'Mouse::Meta::Attribute');
+ does_ok($attr, 'MouseX::Getopt::Meta::Attribute::Trait');
can_ok($attr, 'cmd_flag');
can_ok($attr, 'cmd_aliases');
6 t/007_nogetopt_trait.t
View
@@ -7,14 +7,14 @@ use Test::More tests => 9;
use Test::Exception;
BEGIN {
- use_ok('MooseX::Getopt');
+ use_ok('MouseX::Getopt');
}
{
package App;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt';
+ with 'MouseX::Getopt';
has 'data' => (
traits => ['Getopt'],
22 t/008_configfromfile.t
View
@@ -7,9 +7,9 @@ use Test::Exception;
use Test::More;
use File::Spec;
-if ( !eval { require MooseX::ConfigFromFile } )
+if ( !eval { require MouseX::ConfigFromFile } )
{
- plan skip_all => 'Test requires MooseX::ConfigFromFile';
+ plan skip_all => 'Test requires MouseX::ConfigFromFile';
}
else
{
@@ -19,9 +19,9 @@ else
{
package App;
- use Moose;
- with 'MooseX::Getopt';
- with 'MooseX::ConfigFromFile';
+ use Mouse;
+ with 'MouseX::Getopt';
+ with 'MouseX::ConfigFromFile';
has 'config_from_override' => (
is => 'ro',
@@ -68,7 +68,7 @@ else
{
package App::DefaultConfigFile;
- use Moose;
+ use Mouse;
extends 'App';
has '+configfile' => (
@@ -79,7 +79,7 @@ else
{
package App::DefaultConfigFileCodeRef;
- use Moose;
+ use Mouse;
extends 'App';
has '+configfile' => (
@@ -193,17 +193,17 @@ else
{
package BaseApp::WithConfig;
- use Moose;
- with 'MooseX::ConfigFromFile';
+ use Mouse;
+ with 'MouseX::ConfigFromFile';
sub get_config_from_file { return {}; }
}
{
package DerivedApp::Getopt;
- use Moose;
+ use Mouse;
extends 'BaseApp::WithConfig';
- with 'MooseX::Getopt';
+ with 'MouseX::Getopt';
}
# With DerivedApp, the Getopt role was applied at a different level
6 t/009_gld_and_explicit_options.t
View
@@ -10,14 +10,14 @@ BEGIN {
eval 'use Getopt::Long::Descriptive;';
plan skip_all => "Getopt::Long::Descriptive required for this test" if $@;
plan tests => 5;
- use_ok('MooseX::Getopt');
+ use_ok('MouseX::Getopt');
}
{
package Testing::Foo;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt';
+ with 'MouseX::Getopt';
has 'bar' => (
is => 'ro',
6 t/010_dashes.t
View
@@ -9,14 +9,14 @@ use Test::Exception;
BEGIN {
- use_ok('MooseX::Getopt');
+ use_ok('MouseX::Getopt');
}
{
package App;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt::Dashes';
+ with 'MouseX::Getopt::Dashes';
has 'some_thingy' => ( is => 'ro', isa => 'Str', default => 'foo' );
has 'another_thingy' => ( is => 'ro', isa => 'Str', default => 'foo', cmd_flag => 'another_thingy', traits => [ 'Getopt' ], );
6 t/100_gld_default_bug.t
View
@@ -10,14 +10,14 @@ BEGIN {
eval 'use Getopt::Long::Descriptive;';
plan skip_all => "Getopt::Long::Descriptive required for this test" if $@;
plan tests => 5;
- use_ok('MooseX::Getopt');
+ use_ok('MouseX::Getopt');
}
{
package Engine::Foo;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt';
+ with 'MouseX::Getopt';
has 'nproc' => (
metaclass => 'Getopt',
8 t/101_argv_bug.t
View
@@ -5,13 +5,13 @@ use warnings;
use Test::More tests => 3;
-use MooseX::Getopt;
+use MouseX::Getopt;
{
package App;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt';
+ with 'MouseX::Getopt';
has 'length' => (
is => 'ro',
@@ -24,7 +24,7 @@ use MooseX::Getopt;
isa => 'Bool',
default => 0,
);
- no Moose;
+ no Mouse;
}
{
16 t/102_basic_basic.t
View
@@ -6,17 +6,17 @@ use warnings;
use Test::More tests => 69;
BEGIN {
- use_ok('MooseX::Getopt::Basic');
+ use_ok('MouseX::Getopt::Basic');
}
{
package App;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt::Basic';
+ with 'MouseX::Getopt::Basic';
has 'data' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ metaclass => 'MouseX::Getopt::Meta::Attribute',
is => 'ro',
isa => 'Str',
default => 'file.dat',
@@ -32,7 +32,7 @@ BEGIN {
);
has 'horse' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ metaclass => 'MouseX::Getopt::Meta::Attribute',
is => 'ro',
isa => 'Str',
default => 'bray',
@@ -70,7 +70,7 @@ BEGIN {
);
has '_private_stuff_cmdline' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ metaclass => 'MouseX::Getopt::Meta::Attribute',
is => 'ro',
isa => 'Int',
default => 832,
@@ -81,8 +81,8 @@ BEGIN {
foreach my $attr_name (qw(data cow horse _private_stuff_cmdline)) {
my $attr = App->meta->get_attribute($attr_name);
- isa_ok($attr, 'Moose::Meta::Attribute');
- isa_ok($attr, 'MooseX::Getopt::Meta::Attribute');
+ isa_ok($attr, 'Mouse::Meta::Attribute');
+ isa_ok($attr, 'MouseX::Getopt::Meta::Attribute');
can_ok($attr, 'cmd_flag');
can_ok($attr, 'cmd_aliases');
}
4 t/103_uc_bug.t
View
@@ -7,8 +7,8 @@ use Test::More tests => 3;
{
package App;
- use Moose;
- with qw(MooseX::Getopt);
+ use Mouse;
+ with qw(MouseX::Getopt);
has 'TrackingNumber' => (
is => 'rw',
4 t/104_override_usage.t
View
@@ -5,9 +5,9 @@ use Test::Exception;
{
package MyScript;
- use Moose;
+ use Mouse;
- with 'MooseX::Getopt';
+ with 'MouseX::Getopt';
has foo => ( isa => 'Int', is => 'ro', documentation => 'A foo' );
16 t/105_uc_bug_more.t
View
@@ -1,18 +1,18 @@
use strict;
use warnings;
use Test::More;
-use Moose ();
-use Moose::Meta::Class;
+use Mouse ();
+use Mouse::Meta::Class;
foreach my $role (qw/
- MooseX::Getopt
- MooseX::Getopt::GLD
- MooseX::Getopt::Basic
+ MouseX::Getopt
+ MouseX::Getopt::GLD
+ MouseX::Getopt::Basic
/) {
- Class::MOP::load_class($role);
+ Mouse::Util::load_class($role);
- my $meta = Moose::Meta::Class->create_anon_class(
- superclasses => ['Moose::Object'],
+ my $meta = Mouse::Meta::Class->create_anon_class(
+ superclasses => ['Mouse::Object'],
);
$meta->add_attribute('Debug', traits => ['Getopt'], isa => 'Bool',
cmd_aliases => ['d'], is => 'ro');
16 t/106_no_ignore_case.t
View
@@ -1,18 +1,18 @@
use strict;
use warnings;
use Test::More;
-use Moose ();
-use Moose::Meta::Class;
+use Mouse ();
+use Mouse::Meta::Class;
foreach my $role (qw/
- MooseX::Getopt
- MooseX::Getopt::GLD
- MooseX::Getopt::Basic
+ MouseX::Getopt
+ MouseX::Getopt::GLD
+ MouseX::Getopt::Basic
/) {
- Class::MOP::load_class($role);
+ Mouse::Util::load_class($role);
- my $meta = Moose::Meta::Class->create_anon_class(
- superclasses => ['Moose::Object'],
+ my $meta = Mouse::Meta::Class->create_anon_class(
+ superclasses => ['Mouse::Object'],
);
$meta->add_attribute('BigD', traits => ['Getopt'], isa => 'Bool',
cmd_aliases => ['D'], is => 'ro');
14 t/107_no_auto_help.t
View
@@ -6,15 +6,15 @@
# Summary: If we disable the "auto_help" option in Getopt::Long, then
# getoptions() will not call into pod2usage() (causing program termination)
-# when --help is passed (and MooseX::ConfigFromFile is in use).
+# when --help is passed (and MouseX::ConfigFromFile is in use).
use strict;
use warnings;
use Test::More;
BEGIN {
-plan skip_all => 'This test needs MooseX::SimpleConfig 0.07'
- unless eval { require MooseX::SimpleConfig && MooseX::SimpleConfig->VERSION(0.07); };
+plan skip_all => 'This test needs MouseX::SimpleConfig 0.07'
+ unless eval { require MouseX::SimpleConfig && MouseX::SimpleConfig->VERSION(0.07); };
}
my $fail_on_exit = 1;
@@ -22,10 +22,10 @@ my $fail_on_exit = 1;
package Class;
use strict; use warnings;
- use Moose;
+ use Mouse;
with
- 'MooseX::SimpleConfig',
- 'MooseX::Getopt';
+ 'MouseX::SimpleConfig',
+ 'MouseX::Getopt';
# this is a hacky way of being able to check that we made it past the
# $opt_parser->getoptions() call in new_with_options, because it is
@@ -38,7 +38,7 @@ my $fail_on_exit = 1;
},
);
- no Moose;
+ no Mouse;
1;
}
12 t/108_usage_attr.t
View
@@ -11,21 +11,21 @@ use Test::More tests => 3;
{
package MyClass;
use strict; use warnings;
- use Moose;
- with 'MooseX::Getopt';
+ use Mouse;
+ with 'MouseX::Getopt';
}
-Moose::Meta::Class->create('MyClassWithBasic',
+Mouse::Meta::Class->create('MyClassWithBasic',
superclasses => ['MyClass'],
- roles => [ 'MooseX::Getopt::Basic' ],
+ roles => [ 'MouseX::Getopt::Basic' ],
);
my $basic_obj = MyClassWithBasic->new_with_options();
ok(!$basic_obj->meta->has_attribute('usage'), 'basic class has no usage attribute');
-Moose::Meta::Class->create('MyClassWithGLD',
+Mouse::Meta::Class->create('MyClassWithGLD',
superclasses => ['MyClass'],
- roles => [ 'MooseX::Getopt' ],
+ roles => [ 'MouseX::Getopt' ],
);
my $gld_obj = MyClassWithGLD->new_with_options();
4 t/109_help_flag.t
View
@@ -23,8 +23,8 @@ use Test::Exception;
{
package MyClass;
use strict; use warnings;
- use Moose;
- with 'MooseX::Getopt';
+ use Mouse;
+ with 'MouseX::Getopt';
}
# before fix, prints this on stderr:
18 t/110_sort_usage_by_attr_order.t
View
@@ -3,7 +3,7 @@
# attributes, except the order is not deterministic (rather, it uses the order
# in which the attributes are stored in the metaclass 'attributes' hash).
# Let's sort them by insertion order, which should lead to nicer output:
-# If MooseX::Getopt is applied early, the help options will be on top
+# If MouseX::Getopt is applied early, the help options will be on top
# the help options will always be on top (assuming this role is applied
# early), followed by options added by parent classes and roles, and then
# options added by this class.
@@ -15,8 +15,8 @@ use Test::Exception;
{
package MyClass;
use strict; use warnings;
- use Moose;
- with 'MooseX::Getopt';
+ use Mouse;
+ with 'MouseX::Getopt';
has $_ => (
is => 'ro', isa => 'Str',
@@ -27,13 +27,13 @@ use Test::Exception;
my $obj = MyClass->new_with_options();
-my $expected = <<USAGE;
+my $expected = <<'USAGE';
usage: 110_sort_usage_by_attr_order.t [-?] [long options...]
- -? --usage --help Prints this usage information.
- --foo Documentation for "foo"
- --bar Documentation for "bar"
- --baz Documentation for "baz"
+ -? --usage --help Prints this usage information.
+ --foo Documentation for "foo"
+ --bar Documentation for "bar"
+ --baz Documentation for "baz"
USAGE
-
+$expected =~ s/^[ ]{4}/\t/xmsg;
is($obj->usage->text, $expected, 'Usage text has nicely sorted options');
Please sign in to comment.
Something went wrong with that request. Please try again.