2 package MooseX::Getopt::Meta::Attribute;
4 use Moose::Util::TypeConstraints;
7 our $AUTHORITY = 'cpan:STEVAN';
9 extends 'Moose::Meta::Attribute'; # << Moose extending Moose :)
10 with 'MooseX::Getopt::Meta::Attribute::Trait';
14 # register this as a metaclass alias ...
15 package # stop confusing PAUSE
16 Moose::Meta::Attribute::Custom::Getopt;
17 sub register_implementation { 'MooseX::Getopt::Meta::Attribute' }
27 MooseX::Getopt::Meta::Attribute - Optional meta attribute for custom option names
34 with 'MooseX::Getopt';
37 metaclass => 'MooseX::Getopt::Meta::Attribute',
40 default => 'file.dat',
42 # tells MooseX::Getopt to use --somedata as the
43 # command line flag instead of the normal
44 # autogenerated one (--data)
45 cmd_flag => 'somedata',
47 # tells MooseX::Getopt to also allow --moosedata,
48 # -m, and -d as aliases for this same option on
50 cmd_aliases => [qw/ moosedata m d /],
52 # Or, you can use a plain scalar for a single alias:
58 This is a custom attribute metaclass which can be used to specify a
59 the specific command line flag to use instead of the default one
60 which L<MooseX::Getopt> will create for you.
62 This is certainly not the prettiest way to go about this, but for
63 now it works for those who might need such a feature.
65 =head2 Custom Metaclass alias
67 This now takes advantage of the Moose 0.19 feature to support
68 custom attribute metaclass aliases. This means you can also
69 use this as the B<Getopt> alias, like so:
71 has 'foo' => (metaclass => 'Getopt', cmd_flag => 'f');
75 These methods are of little use to most users, they are used interally
76 within L<MooseX::Getopt>.
82 Changes the commandline flag to be this value, instead of the default,
83 which is the same as the attribute name.
87 Adds more aliases for this commandline flag, useful for short options
92 =item B<has_cmd_aliases>
100 All complex software has bugs lurking in it, and this module is no
101 exception. If you find a bug please either email me, or add the bug
106 Stevan Little E<lt>stevan@iinteractive.comE<gt>
108 Brandon L. Black, E<lt>blblack@gmail.comE<gt>
110 =head1 COPYRIGHT AND LICENSE
112 Copyright 2007-2008 by Infinity Interactive, Inc.
114 L<http://www.iinteractive.com>
116 This library is free software; you can redistribute it and/or modify
117 it under the same terms as Perl itself.