Skip Menu |

This queue is for tickets about the App-Software-License CPAN distribution.

Report information
The Basics
Id: 82924
Status: resolved
Priority: 0/
Queue: App-Software-License

People
Owner: ether [...] cpan.org
Requestors: RWSTAUNER [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.01
Fixed in: 0.03



Subject: Year option doesn't accept argument
*$ software-license --year=2011 --license=BSD Option year does not take an argument usage: software-license [-?h] [long options...] -h -? --usage --help Prints this usage information. --holder --year --license --configfile --type It says year doesn't take an argument, but I don't know what "--year" should do without one. I think MooseX::Getopt doesn't recognize the "Maybe" type. Dropping that and using a predicate seems to work.
Subject: app-software-license-year.patch
diff --git a/lib/App/Software/License.pm b/lib/App/Software/License.pm index de9e9fc..79a2eea 100644 --- a/lib/App/Software/License.pm +++ b/lib/App/Software/License.pm @@ -23,8 +23,8 @@ has holder => ( has year => ( is => 'ro', - isa => Maybe[Num], - default => undef, + isa => Num, + predicate => 'has_year', ); @@ -64,7 +64,7 @@ sub _build__software_license { Class::MOP::load_class($class); return $class->new({ holder => $self->holder, - year => $self->year, + ($self->has_year ? (year => $self->year) : ()), }); } diff --git a/t/options.t b/t/options.t new file mode 100644 index 0000000..2de6b73 --- /dev/null +++ b/t/options.t @@ -0,0 +1,40 @@ +use strict; +use warnings; +use Test::More 0.88; +use File::Spec::Functions qw( catfile ); # core + +use App::Software::License; + +my $holder = 'A.Holder'; +my $year = (localtime)[5] + 1900; + +sub test_opts { + my ($argv, $re, $desc) = @_; + local @ARGV = @$argv; + my $holder = 'A.Holder'; + like( + App::Software::License->new_with_options->_software_license->notice, + $re, + $desc, + ); +} + +test_opts( + [qw( --holder=A.Holder --license=BSD )], + qr/^\QThis software is Copyright (c) $year by $holder.\E/, + 'basic args', +); + +test_opts( + [qw( --holder=A.Holder BSD )], + qr/^\QThis software is Copyright (c) $year by $holder.\E/, + 'license as last (non-option) argument', +); + +test_opts( + [qw( --year=2000 --holder=A.Holder BSD )], + qr/^\QThis software is Copyright (c) 2000 by $holder.\E/, + 'specify year', +); + +done_testing;
On Wed Jan 23 19:23:11 2013, RWSTAUNER wrote: Show quoted text
> I think MooseX::Getopt doesn't recognize the "Maybe" type. > Dropping that and using a predicate seems to work.
Yes, MooseX::Getopt doesn't understand either Maybe[Foo] or Foo|Undef, as undef can't really be passed on the command line. :) However, Foo|Bool should work properly, so if you just said --year with no argument you'd get a 1 in the attribute (not that a boolean makes sense for this argument).
So, what would be the appropriate solution for this? I just found this issue again.
On 2014-01-25 06:26:07, RWSTAUNER wrote: Show quoted text
> So, what would be the appropriate solution for this? > I just found this issue again.
Hey, I just ran into this again! Fixed finally in 0.03 :)