App-Cmd
App-Cmd copied to clipboard
Usage is lost if a command uses Moose
If a command class uses Moose (or Mouse) the "Usage" output will be lost. Even with "no Moose".
$ perl -Ilib bin/test foo
Error: This will never work
Usage: at /Users/schwern/perl5/perlbrew/perls/perl-5.18.1-thread/lib/site_perl/5.18.1/App/Cmd/Command.pm line 90.
See https://gist.github.com/schwern/10081851 for test code.
The gist, here for posterity:
#!/usr/bin/perl
{
package App::Cmd::Bug;
use App::Cmd::Setup -app;
BEGIN { $INC{"App/Cmd/Bug.pm"} = 1; }
}
{
package App::Cmd::Bug::Command::foo;
# Using Moose causes the usage description to break.
use Moose;
no Moose;
use App::Cmd::Bug -command;
sub validate_args {
my $self = shift;
$self->usage_error("This will never work");
return;
}
}
use App::Cmd::Bug;
App::Cmd::Bug->run;
Using Moose gets Moose::Object into @INC
before App::Command::Command, which is put there by use App::Cmd::Bug -command
, so the "wrong" new run. The only likely solution, here, is documentation.