From: Brandon L Black Date: Mon, 28 Jan 2008 04:34:18 +0000 (+0000) Subject: 0.11, required not necessarily required X-Git-Tag: 0_15~19 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6c329add9865bff293ea15cb1ce1c3478bb50d4d;p=gitmo%2FMooseX-Getopt.git 0.11, required not necessarily required --- diff --git a/ChangeLog b/ChangeLog index 398ed92..f925121 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ Revision history for Perl extension MooseX-Getopt +0.11 Sun. Jan. 27, 2008 + * MooseX::Getopt + - Commandline option shouldn't be required in the + case that the given "required" attribute has + a default or a builder method. + 0.10 Wed. Jan. 23, 2008 * MooseX::Getopt - Support default configfile attribute when diff --git a/lib/MooseX/Getopt.pm b/lib/MooseX/Getopt.pm index d7898f7..ddbba8c 100644 --- a/lib/MooseX/Getopt.pm +++ b/lib/MooseX/Getopt.pm @@ -9,7 +9,7 @@ use MooseX::Getopt::Meta::Attribute::NoGetopt; use Getopt::Long (); # GLD uses it anyway, doesn't hurt use constant HAVE_GLD => not not eval { require Getopt::Long::Descriptive }; -our $VERSION = '0.10'; +our $VERSION = '0.11'; our $AUTHORITY = 'cpan:STEVAN'; has ARGV => (is => 'rw', isa => 'ArrayRef', metaclass => "NoGetopt"); @@ -175,7 +175,7 @@ sub _attrs_to_options { name => $name, init_arg => $attr->init_arg, opt_string => $opt_string, - required => $attr->is_required, + required => $attr->is_required && !$attr->has_default && !$attr->has_builder, ( ( $attr->has_default && ( $attr->is_default_a_coderef xor $attr->is_lazy ) ) ? ( default => $attr->default({}) ) : () ), ( $attr->has_documentation ? ( doc => $attr->documentation ) : () ), }