Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Using "with 'MooseX::Getopt::Usage' throwing error with MooseX::App::Cmd::Command

by choroba (Cardinal)
on Feb 05, 2018 at 17:18 UTC ( [id://1208500]=note: print w/replies, xml ) Need Help??


in reply to Using "with 'MooseX::Getopt::Usage' throwing error with MooseX::App::Cmd::Command

I fear you didn't provide enough information.

The following works for me:

#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; { package My; use Moose; extends 'MooseX::App::Cmd::Command'; with qw{ MooseX::Getopt::Usage }; has test => ( traits => [qw[ Getopt ]], isa => 'Bool', is => 'rw', cmd_aliases => 't', documentation => 'test me', ); sub execute { my ($self, $opt, $args) = @_; say $self->test; } __PACKAGE__->meta->make_immutable; } my $app = 'My'->new_with_options;

When I call

script.pl --usage

I get the usage back. When, on the other hand, I try with

script.pl --test

It fails with

Required option missing: app
I have no idea where it's coming from, as the documentation of neither MooseX::App::Cmd::Command, MooseX::Getopt::Usage, MooseX::App::Cmd, nor App::Cmd mentions it.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Using "with 'MooseX::Getopt::Usage' throwing error with MooseX::App::Cmd::Command
by nysus (Parson) on Feb 05, 2018 at 17:51 UTC

    You're right. I did oversimplify. I'm using this in conjunction with MooseX::App::Cmd. So the $app never gets called with the new_with_options method. Instead, everything is handled by MooseX::App::Cmd.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1208500]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-20 02:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found