MouseX...:Trait(3pm)

πŸ“¦
version 0.38 Β· 4 versions
, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ’– MouseX::Getopt::Meta::Attribute::Trait(3pm) πŸ’–

okay so bestie, this is a page from the User Contributed Perl Documentation, and it's all about MouseX::Getopt::Meta::Attribute::Trait β€” the optional meta attribute trait that lets you name your own command line options instead of letting the computer pick for you. she's giving custom option names and honestly? iconic. πŸ‘‘


✨ NAME ✨

MouseX::Getopt::Meta::Attribute::Trait β€” optional meta attribute trait for custom option names πŸ’…


🌸 SYNOPSIS 🌸

package App;
use Mouse;

with 'MouseX::Getopt';

has 'data' => (
    traits    => [ 'Getopt' ],
    is        => 'ro',
    isa       => 'Str',
    default   => 'file.dat',

    # tells MouseX::Getopt to use --somedata as the
    # command line flag instead of the normal
    # autogenerated one (--data)
    cmd_flag  => 'somedata',

    # tells MouseX::Getopt to also allow --moosedata,
    # -m, and -d as aliases for this same option on
    # the commandline.
    cmd_aliases => [qw/ moosedata m d /],

    # Or, you can use a plain scalar for a single alias:
    cmd_aliases => 'm',
);

like. look at her. she's literally telling MouseX::Getopt "no babe, I pick the flag name" and MouseX::Getopt is like "okay periodt" 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

This is a custom attribute metaclass trait, and what it does is let you specify the specific command line flag to use β€” instead of the default one that MouseX::Getopt would just... make up for you. rude of it, honestly. so you take the wheel. πŸŽ€

⭐ cmd_flag

Changes the commandline flag to be this value, instead of the default β€” and the default is literally just the same as the attribute name. no cap. so if you don't set this, your attribute name is your flag. that's the whole vibe.

🌈 cmd_aliases

Adds more aliases for this commandline flag! super useful for short options and such β€” you know, the little single-letter guys. one flag, many names. main character energy, she contains multitudes. πŸ’œ

🧚 has_cmd_flag

🧚 has_cmd_aliases

(yes bestie, those two are just... listed. they exist. the manpage says so and I do not make the rules. 🌸)


🫢 reminder: don't sleep on cmd_aliases β€” a plain scalar gets you one alias, and an arrayref like [qw/ moosedata m d /] gets you the whole squad. pick your fighter.

and that's the whole page, bestie!! you ate. no crumbs left. πŸ’…βœ¨

this was perl v5.32.1, dated 2021-09-16 β€” shouting out the source and the date, mwah πŸŽ€

πŸ“¦ where this page comes from