4 use Moose::Util::TypeConstraints;
7 our $AUTHORITY = 'cpan:STEVAN';
9 extends 'Moose::Meta::Attribute'; # << Moose extending Moose :)
14 predicate => 'has_cmd_flag',
17 # This subtype is to support scalar -> arrayref coercion
18 # without polluting the built-in types
19 subtype '_MooseX_Getopt_CmdAliases'
23 coerce '_MooseX_Getopt_CmdAliases'
27 has 'cmd_aliases' => (
29 isa => '_MooseX_Getopt_CmdAliases',
30 predicate => 'has_cmd_aliases',
36 # register this as a metaclass alias ...
37 package Moose::Meta::Attribute::Custom::Getopt;
38 sub register_implementation { 'MooseX::Getopt::Meta::Attribute' }
48 MooseX::Getopt::Meta::Attribute - Optional meta attribute for custom option names
55 with 'MooseX::Getopt';
58 metaclass => 'MooseX::Getopt::Meta::Attribute',
61 default => 'file.dat',
63 # tells MooseX::Getopt to use --somedata as the
64 # command line flag instead of the normal
65 # autogenerated one (--data)
66 cmd_flag => 'somedata',
68 # tells MooseX::Getopt to also allow --moosedata,
69 # -m, and -d as aliases for this same option on
71 cmd_aliases => [qw/ moosedata m d /],
73 # Or, you can use a plain scalar for a single alias:
79 This is a custom attribute metaclass which can be used to specify a
80 the specific command line flag to use instead of the default one
81 which L<MooseX::Getopt> will create for you.
83 This is certainly not the prettiest way to go about this, but for
84 now it works for those who might need such a feature.
86 =head2 Custom Metaclass alias
88 This now takes advantage of the Moose 0.19 feature to support
89 custom attribute metaclass aliases. This means you can also
90 use this as the B<Getopt> alias, like so:
92 has 'foo' => (metaclass => 'Getopt', cmd_flag => 'f');
96 These methods are of little use to most users, they are used interally
97 within L<MooseX::Getopt>.
103 Changes the commandline flag to be this value, instead of the default,
104 which is the same as the attribute name.
108 Adds more aliases for this commandline flag, useful for short options
111 =item B<has_cmd_flag>
113 =item B<has_cmd_aliases>
121 All complex software has bugs lurking in it, and this module is no
122 exception. If you find a bug please either email me, or add the bug
127 Stevan Little E<lt>stevan@iinteractive.comE<gt>
129 Brandon L. Black, E<lt>blblack@gmail.comE<gt>
131 =head1 COPYRIGHT AND LICENSE
133 Copyright 2007 by Infinity Interactive, Inc.
135 L<http://www.iinteractive.com>
137 This library is free software; you can redistribute it and/or modify
138 it under the same terms as Perl itself.