MooseX...tribute(3pm)

πŸ’– MooseX::Getopt::Meta::Attribute β€” the vibe ✨

okay so bestie, welcome to MooseX::Getopt::Meta::Attribute, a page from the User Contributed Perl Documentation. it's the optional meta attribute that lets you name your own command-line options. version 0.78, she's iconic, she's niche, let's go πŸŽ€


🌸 SYNOPSIS 🌸

package App;
use Moose;

with 'MooseX::Getopt';

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

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

    # tells MooseX::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 go πŸ’… she's just a package, she's doing Moose, she's got a with 'MooseX::Getopt', and then she's out here customizing flags. main character energy fr fr.


✨ DESCRIPTION ✨

so this is a custom attribute metaclass πŸ’– and what it does is let you pick the exact command line flag you wanna use β€” instead of the default one that MooseX::Getopt would just autogenerate for you. no cap.

ngl, this is certainly not the prettiest way to go about any of this πŸ™ˆ but for now? it works. for the people who need such a feature? it works for them. periodt.

πŸ¦‹ Use 'traits' instead of 'metaclass'

okay so you should rarely ever need to explicitly set the attribute metaclass. like, barely ever. the much-preferred move is to just provide a trait β€” which is a role applied to the attribute metaclass β€” because that lets other code come in later and further modify the attribute by applying additional roles. it's giving collaboration ✨

so, bestie, try this first:

has 'foo' => (traits => ['Getopt'], cmd_flag => 'f');

🌈 Custom Metaclass alias

this one now takes advantage of the Moose 0.19 feature that supports custom attribute metaclass aliases πŸŽ€ which means you can also use it as the Getopt alias, like so:

has 'foo' => (metaclass => 'Getopt', cmd_flag => 'f');

ate. no notes. πŸ’…


πŸ‘‘ METHODS πŸ‘‘

cmd_flag

changes the command-line flag to be this value, instead of the default β€” and the default is the same as the attribute name. simple as that πŸ’–

cmd_aliases

adds more aliases for this command-line flag. super useful for short options and such 🩷

has_cmd_flag

yep. she exists. 🌸

has_cmd_aliases

her too. twin energy 🫢


🫢 SUPPORT 🫢

bugs may be submitted through the RT bug tracker β€” https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Getopt β€” or by email at bug-MooseX-Getopt@rt.cpan.org. don't be shy, tell them everything πŸ’Œ

there's also a mailing list available for users of this distribution, at http://lists.perl.org/list/moose.html. join the chat, it's a vibe ✨

and there's an irc channel too, for users of this distribution: #moose on irc.perl.org β€” irc://irc.perl.org/#moose. come hang out, iykyk πŸ’œ


πŸ’œ AUTHOR πŸ’œ

Stevan Little <stevan@iinteractive.com> β€” king behavior, honestly πŸ‘‘


this software is copyright (c) 2007 by Infinity Interactive, Inc.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay πŸŽ€


πŸ’€ reminder bestie: every flag, every alias, every trait β€” copy them exactly. no renaming, no "fixing", no merging, no inventing. the vibe is mine, the facts are hers. periodt.

okay bye ily, this was MooseX::Getopt::Meta::Attribute, page generated by perl v5.40.0 on 2025-01-11 β€” mwah, go write some gorgeous flags πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from