{"id":7403,"date":"2022-12-20T19:37:57","date_gmt":"2022-12-20T22:37:57","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/moosexgetoptmetaattribute-man3\/"},"modified":"2022-12-20T19:37:57","modified_gmt":"2022-12-20T22:37:57","slug":"moosexgetoptmetaattribute-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/moosexgetoptmetaattribute-man3\/","title":{"rendered":"MooseX::Getopt::Meta::Attribute (man3)"},"content":{"rendered":"<h1 align=\"center\">MooseX::Getopt::Meta::Attribute<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#VERSION\">VERSION<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#METHODS\">METHODS<\/a><br \/> <a href=\"#SUPPORT\">SUPPORT<\/a><br \/> <a href=\"#AUTHOR\">AUTHOR<\/a><br \/> <a href=\"#COPYRIGHT AND LICENSE\">COPYRIGHT AND LICENSE<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">MooseX::Getopt::Meta::Attribute \u2212 Optional meta attribute for custom option names<\/p>\n<h2>VERSION <a name=\"VERSION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">version 0.74<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">package App; <br \/> use Moose; <br \/> with &#8216;MooseX::Getopt&#8217;; <br \/> has &#8216;data&#8217; => ( <br \/> metaclass => &#8216;Getopt&#8217;, <br \/> is => &#8216;ro&#8217;, <br \/> isa => &#8216;Str&#8217;, <br \/> default => &#8216;file.dat&#8217;, <br \/> # tells MooseX::Getopt to use \u2212\u2212somedata as the <br \/> # command line flag instead of the normal <br \/> # autogenerated one (\u2212\u2212data) <br \/> cmd_flag => &#8216;somedata&#8217;, <br \/> # tells MooseX::Getopt to also allow \u2212\u2212moosedata, <br \/> # \u2212m, and \u2212d as aliases for this same option on <br \/> # the commandline. <br \/> cmd_aliases => [qw\/ moosedata m d \/], <br \/> # Or, you can use a plain scalar for a single alias: <br \/> cmd_aliases => &#8216;m&#8217;, <br \/> );<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This is a custom attribute metaclass which can be used to specify a the specific command line flag to use instead of the default one which MooseX::Getopt will create for you.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This is certainly not the prettiest way to go about this, but for now it works for those who might need such a feature.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Use \u2019traits\u2019 instead of \u2019metaclass\u2019<\/b> <br \/> You should rarely need to explicitly set the attribute metaclass. It is much preferred to simply provide a trait (a role applied to the attribute metaclass), which allows other code to further modify the attribute by applying additional roles.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Therefore, you should first try to do this:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">has &#8216;foo&#8217; => (traits => [&#8216;Getopt&#8217;], cmd_flag => &#8216;f&#8217;);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Custom Metaclass alias<\/b> <br \/> This now takes advantage of the Moose 0.19 feature to support custom attribute metaclass aliases. This means you can also use this as the <b>Getopt<\/b> alias, like so:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">has &#8216;foo&#8217; => (metaclass => &#8216;Getopt&#8217;, cmd_flag => &#8216;f&#8217;);<\/p>\n<h2>METHODS <a name=\"METHODS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>cmd_flag<\/b> <br \/> Changes the command-line flag to be this value, instead of the default, which is the same as the attribute name.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>cmd_aliases<\/b> <br \/> Adds more aliases for this command-line flag, useful for short options and such.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>has_cmd_flag <br \/> has_cmd_aliases<\/b><\/p>\n<h2>SUPPORT <a name=\"SUPPORT\"><\/a> <\/h2>\n<p style=\"margin-left:11%;\">Bugs may be submitted through the <small>RT<\/small> bug tracker <https:\/\/rt.cpan.org\/Public\/Dist\/Display.html?Name=MooseX-Getopt> (or bug\u2212MooseX\u2212Getopt@rt.cpan.org <mailto:bug-MooseX-Getopt@rt.cpan.org>).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">There is also a mailing list available for users of this distribution, at <http:\/\/lists.perl.org\/list\/moose.html>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">There is also an irc channel available for users of this distribution, at &#8220;#moose&#8221; on &#8220;irc.perl.org&#8221; <irc:\/\/irc.perl.org\/#moose>.<\/p>\n<h2>AUTHOR <a name=\"AUTHOR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Stevan Little <stevan@iinteractive.com><\/p>\n<h2>COPYRIGHT AND LICENSE <a name=\"COPYRIGHT AND LICENSE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This software is copyright (c) 2007 by Infinity Interactive, Inc.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This is free software; you can redistribute it and\/or modify it under the same terms as the Perl 5 programming language system itself.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  MooseX::Getopt::Meta::Attribute \u2212 Optional meta attribute for custom option names <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3007,3716],"class_list":["post-7403","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-man3","tag-moosexgetoptmetaattribute"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7403","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7403"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7403\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}