MouseX...Getopt(3pm)

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

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

okay bestie, welcome to the perl corner of the internet ✨ this one lives in the User Contributed Perl Documentation collection, and it is so much simpler than that giant name makes it look, fr fr πŸŽ€


🌸 NAME 🌸

MouseX::Getopt::Meta::Attribute::Trait::NoGetopt β€” the optional meta attribute trait for when you wanna just... ignore a param πŸ™ˆ

Like, that's it. That's the whole job. It's giving "not my problem" energy and honestly? iconic πŸ’…


✨ SYNOPSIS ✨

okay so picture this, you got a package and you want MouseX::Getopt doing its thing, but there's ONE attribute you want it to keep its hands off of. Here's the move:

package App;
use Mouse;

with 'MouseX::Getopt';

has 'data' => (
    traits  => [ 'NoGetopt' ],  # do not attempt to capture this param
    is      => 'ro',
    isa     => 'Str',
    default => 'file.dat',
);

see that comment up there? # do not attempt to capture this param β€” that's the whole vibe of this module in one line, no cap πŸ”₯


πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea β˜• β€” this is a custom attribute metaclass trait, and what it does is let you say "hey, this specific attribute? do NOT let MouseX::Getopt process it" πŸ’€

And the way you do that is genuinely so easy it's almost silly. All you gotta do is specify the NoGetopt metaclass trait, like:

has 'foo' => (traits => [ 'NoGetopt', ... ], ... );

boom. Done. That attribute is now off-limits to the getopt machinery and it will live its best quiet life 🫢

tl;dr bestie: slap traits => [ 'NoGetopt' ] on the attribute you want skipped, and MouseX::Getopt will politely pretend it doesn't exist. periodt πŸ‘‘

and that's the whole page!! 🌈 if you were wondering, this lil doc is from perl v5.32.1, dated 2021-09-16, and it's filed right here under MouseX...Getopt(3pm) in the User Contributed Perl Documentation πŸŽ€

mwah, go write some slay code, bestie πŸ’œβœ¨πŸ§šβ€β™€οΈ

πŸ“¦ where this page comes from