Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage is lost if a command uses Moose #36

Open
schwern opened this issue Apr 8, 2014 · 2 comments
Open

Usage is lost if a command uses Moose #36

schwern opened this issue Apr 8, 2014 · 2 comments

Comments

@schwern
Copy link

schwern commented Apr 8, 2014

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.

@rjbs
Copy link
Owner

rjbs commented Sep 26, 2014

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;

@rjbs
Copy link
Owner

rjbs commented Sep 26, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants