2 package MooseX::Getopt::Meta::Attribute;
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'
22 coerce '_MooseX_Getopt_CmdAliases'
26 has 'cmd_aliases' => (
28 isa => '_MooseX_Getopt_CmdAliases',
29 predicate => 'has_cmd_aliases',
42 MooseX::Getopt::Meta::Attribute - Optional meta attribute for custom option names
49 with 'MooseX::Getopt';
52 metaclass => 'MooseX::Getopt::Meta::Attribute',
55 default => 'file.dat',
57 # tells MooseX::Getopt to use --somedata as the
58 # command line flag instead of the normal
59 # autogenerated one (--data)
60 cmd_flag => 'somedata',
62 # tells MooseX::Getopt to also allow --moosedata,
63 # -m, and -d as aliases for this same option on
65 cmd_aliases => [qw/ moosedata m d /],
67 # Or, you can use a plain scalar for a single alias:
73 This is a custom attribute metaclass which can be used to specify a
74 the specific command line flag to use instead of the default one
75 which L<MooseX::Getopt> will create for you.
77 This is certainly not the prettiest way to go about this, but for
78 now it works for those who might need such a feature.
82 These methods are of little use to most users, they are used interally
83 within L<MooseX::Getopt>.
89 Changes the commandline flag to be this value, instead of the default,
90 which is the same as the attribute name.
94 Adds more aliases for this commandline flag, useful for short options
99 =item B<has_cmd_aliases>
107 All complex software has bugs lurking in it, and this module is no
108 exception. If you find a bug please either email me, or add the bug
113 Stevan Little E<lt>stevan@iinteractive.comE<gt>
115 =head1 COPYRIGHT AND LICENSE
117 Copyright 2007 by Infinity Interactive, Inc.
119 L<http://www.iinteractive.com>
121 This library is free software; you can redistribute it and/or modify
122 it under the same terms as Perl itself.