--- /dev/null
+pm_to_blib
+inc
+blib
+Makefile
+Makefile.old
+META.yml
+MANIFEST
+MANIFEST.bak
Revision history for Perl extension MooseX-Getopt
-0.19
* MooseX::Getopt
+ - Enable and document the argv parameter to the constructor.
- Applied patches in RT43200 and RT43255
+0.20 Wed. July 9 2009
+ ~ fix MANIFEST.SKIP to avoid double-packaging
+
+0.19 Wed. July 8 2009
+ * MooseX::Getopt
+ - Fix Getopt config spec for --configfile (t0m)
+ - Add support for --usage/--help/--? (drew@drewtaylor.com)
+ - Fix new_with_options to accept a hashref (DOUGDUDE@cpan.org)
+
+ * Tests
+ - Fix warning from tests with new Moose (t0m)
+ - Fix tests on Win32 from RT#44909 (taro-nishino)
+
0.18 Thu. April 9 2009
* MooseX::Getopt::Dashes
- New module, for converting undercores to dashes (ilmari)
+++ /dev/null
-ChangeLog
-inc/Module/AutoInstall.pm
-inc/Module/Install.pm
-inc/Module/Install/AutoInstall.pm
-inc/Module/Install/Base.pm
-inc/Module/Install/Can.pm
-inc/Module/Install/Fetch.pm
-inc/Module/Install/Include.pm
-inc/Module/Install/Makefile.pm
-inc/Module/Install/Metadata.pm
-inc/Module/Install/Win32.pm
-inc/Module/Install/WriteAll.pm
-lib/MooseX/Getopt.pm
-lib/MooseX/Getopt/Dashes.pm
-lib/MooseX/Getopt/Meta/Attribute.pm
-lib/MooseX/Getopt/Meta/Attribute/NoGetopt.pm
-lib/MooseX/Getopt/Meta/Attribute/Trait.pm
-lib/MooseX/Getopt/Meta/Attribute/Trait/NoGetopt.pm
-lib/MooseX/Getopt/OptionTypeMap.pm
-lib/MooseX/Getopt/Strict.pm
-Makefile.PL
-MANIFEST
-META.yml
-README
-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/006_metaclass_traits.t
-t/007_nogetopt_trait.t
-t/008_configfromfile.t
-t/009_gld_and_explicit_options.t
-t/010_dashes.t
-t/100_gld_default_bug.t
-t/pod.t
-t/pod_coverage.t
+^.git
^_build
^Build$
^blib
\.old$
^#.*#$
^\.#
-^TODO$
\ No newline at end of file
+^TODO$
+^MooseX-Getopt
build_requires 'Test::Exception' => '0.21';
tests_recursive();
-auto_install;
+auto_manifest();
WriteAll;
-MooseX::Getopt version 0.18
+MooseX::Getopt version 0.20
===========================
See the individual module documentation for more information
use Getopt::Long (); # GLD uses it anyway, doesn't hurt
use constant HAVE_GLD => not not eval { require Getopt::Long::Descriptive };
-our $VERSION = '0.18';
+our $VERSION = '0.20';
our $AUTHORITY = 'cpan:STEVAN';
has ARGV => (is => 'rw', isa => 'ArrayRef', metaclass => "NoGetopt");
sub _parse_argv {
my ( $class, %params ) = @_;
- local @ARGV = @{ $params{argv} || \@ARGV };
+ local @ARGV = @{ $params{params}{argv} || \@ARGV };
my ( $opt_spec, $name_to_init_arg ) = ( HAVE_GLD ? $class->_gld_spec(%params) : $class->_traditional_spec(%params) );
my $opt_string = join(q{|}, $flag, @aliases);
- if ($attr->has_type_constraint) {
+ if ($attr->name eq 'configfile') {
+ $opt_string .= '=s';
+ }
+ 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)
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
-to have the leading underscore in thier name, you can do this:
+to L<MooseX::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
has '_foo' => (accessor => 'foo', ...);
params from the command line (possibly overriding those in C<%params>)
and then return a newly constructed object.
+The special parameter C<argv>, if specified should point to an array
+reference with an array to use instead of C<@ARGV>.
+
If L<Getopt::Long/GetOptions> fails (due to invalid arguments),
C<new_with_options> will throw an exception.
--help
--usage
-If you have L<Getopt::Long::Descriptive> a the C<usage> param is also passed to
+If you have L<Getopt::Long::Descriptive> the C<usage> param is also passed to
C<new>.
=item B<ARGV>
use Moose;
use Moose::Util::TypeConstraints;
-our $VERSION = '0.18';
+our $VERSION = '0.20';
our $AUTHORITY = 'cpan:STEVAN';
extends 'Moose::Meta::Attribute'; # << Moose extending Moose :)
package MooseX::Getopt::Meta::Attribute::NoGetopt;
use Moose;
-our $VERSION = '0.18';
+our $VERSION = '0.20';
our $AUTHORITY = 'cpan:STEVAN';
extends 'Moose::Meta::Attribute'; # << Moose extending Moose :)
use Moose::Role;
use Moose::Util::TypeConstraints;
-our $VERSION = '0.18';
+our $VERSION = '0.20';
our $AUTHORITY = 'cpan:STEVAN';
has 'cmd_flag' => (
package MooseX::Getopt::Meta::Attribute::Trait::NoGetopt;
use Moose::Role;
-our $VERSION = '0.18';
+our $VERSION = '0.20';
our $AUTHORITY = 'cpan:STEVAN';
no Moose::Role;
use Moose 'confess', 'blessed';
use Moose::Util::TypeConstraints 'find_type_constraint';
-our $VERSION = '0.18';
+our $VERSION = '0.20';
our $AUTHORITY = 'cpan:STEVAN';
my %option_type_map = (
isa => 'Int',
default => 713
);
-
- has '_private_stuff_cmdline' => (
- is => 'ro',
- isa => 'Int',
- default => 832,
- cmd_flag => 'p',
- );
-
}
{
use Test::Exception;
use Test::More;
+use File::Spec;
if ( !eval { require MooseX::ConfigFromFile } )
{
optional_from_config => 'from_config_2',
);
- if ( $file ne '/notused/default' ) {
+ my $cpath = File::Spec->canonpath('/notused/default');
+ if ( $file ne $cpath ) {
$config{config_from_override} = 1;
}
extends 'App';
has '+configfile' => (
- default => '/notused/default',
+ default => File::Spec->canonpath('/notused/default'),
);
}
ok( !$app->config_from_override,
'... config_from_override false as expected' );
- is( $app->configfile, '/notused/default',
+ is( $app->configfile, File::Spec->canonpath('/notused/default'),
'... configfile is /notused/default as expected' );
}
}
ok( $app->config_from_override,
'... config_from_override true as expected' );
- is( $app->configfile, '/notused',
+ is( $app->configfile, File::Spec->canonpath('/notused'),
'... configfile is /notused as expected' );
}
}
--- /dev/null
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 3;
+
+use MooseX::Getopt;
+
+{
+ package App;
+ use Moose;
+
+ with 'MooseX::Getopt';
+
+ has 'length' => (
+ is => 'ro',
+ isa => 'Int',
+ default => 24,
+ );
+
+ has 'verbose' => (
+ is => 'ro',
+ isa => 'Bool',
+ default => 0,
+ );
+ no Moose;
+}
+
+{
+ my $app = App->new_with_options(argv => [ '--verbose', '--length', 50 ]);
+ isa_ok($app, 'App');
+
+ ok($app->verbose, '... verbosity is turned on as expected');
+ is($app->length, 50, '... length is 50 as expected');
+}
+