DOKK / manpages / debian 12 / libmoosex-app-perl / MooseX::App::Role.3pm.en
MooseX::App::Role(3pm) User Contributed Perl Documentation MooseX::App::Role(3pm)

MooseX::App::Role - Define attributes in a role

 package MyApp::Role::SomeRole;
 
 use MooseX::App::Role; # Alo loads Moose::Role
 
 option 'testattr' => (
    isa             => 'rw',
    cmd_tags        => [qw(Important! Nice))],
 );

Enables the 'option' and 'parameter' keywords in your roles.

Alternatively you can also just use attribute traits:

 has 'testattr' => (
    isa             => 'rw',
    traits          => ['AppOption'],   # required
    cmd_type        => 'option',        # required
    cmd_tags        => [qw(Important! Nice))],
 );
2022-10-16 perl v5.34.0