MooseX::App::Role(3)

πŸ’– NAME πŸ’–

MooseX::App::Role(3) β€” Define attributes in a role. That’s the whole vibe, bestie: this is the module for putting attributes in a role, and it’s giving reusable main-character energy. πŸ‘‘


✨ SYNOPSIS ✨

Okay so here’s the exact group-chat screenshot of how it goes:

        package MyApp::Role::SomeRole;

        use MooseX::App::Role; # Alo loads Moose::Role

        option 'testattr' => (
           isa             => 'rw',
           cmd_tags        => [qw(Important! Nice))],
        );

That # Alo loads Moose::Role comment is exactly as printed β€” typo and all, no cap πŸ™ˆ β€” and it’s telling you it also loads Moose::Role.


🌸 DESCRIPTION 🌸

This module enables the option and parameter keywords in your roles. Literally that’s the serve. ✨

Alternatively you can also just use attribute traits:

        has 'testattr' => (
           isa             => 'rw',
           traits          => ['AppOption'],   # required
           cmd_type        => 'option',        # required
           cmd_tags        => [qw(Important! Nice))],
        );

The # required tags on traits => ['AppOption'] and cmd_type => 'option' are not decorative, bestie β€” they’re required. 🚨


Signed off with full main-character energy: this was the MooseX::App::Role(3) page from User Contributed Perl Documentation, perl v5.42.0, dated 2024-08-09. πŸ’…πŸ«Ά

πŸ“¦ where this page comes from