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 π
β COPYRIGHT AND LICENSE β
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
- debian trixie: libmoosex-getopt-perl 0.78-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmoosex-getopt-perl 0.78-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmoosex-getopt-perl 0.78-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms