Bump versions
[gitmo/MooseX-Getopt.git] / lib / MooseX / Getopt / Meta / Attribute.pm
1
2 package MooseX::Getopt::Meta::Attribute;
3 use Moose;
4 use Moose::Util::TypeConstraints;
5
6 our $VERSION   = '0.25';
7 our $AUTHORITY = 'cpan:STEVAN';
8
9 extends 'Moose::Meta::Attribute'; # << Moose extending Moose :)
10    with 'MooseX::Getopt::Meta::Attribute::Trait';
11
12 no Moose;
13
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' }
18
19 1;
20
21 __END__
22
23 =pod
24
25 =head1 NAME
26
27 MooseX::Getopt::Meta::Attribute - Optional meta attribute for custom option names
28
29 =head1 SYNOPSIS
30
31   package App;
32   use Moose;
33   
34   with 'MooseX::Getopt';
35   
36   has 'data' => (
37       metaclass => 'MooseX::Getopt::Meta::Attribute',     
38       is        => 'ro',
39       isa       => 'Str',
40       default   => 'file.dat',
41
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',
46
47       # tells MooseX::Getopt to also allow --moosedata,
48       # -m, and -d as aliases for this same option on
49       # the commandline.
50       cmd_aliases => [qw/ moosedata m d /],
51
52       # Or, you can use a plain scalar for a single alias:
53       cmd_aliases => 'm',
54   );
55
56 =head1 DESCRIPTION
57
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. 
61
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.
64
65 =head2 Custom Metaclass alias
66
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:
70
71   has 'foo' => (metaclass => 'Getopt', cmd_flag => 'f');
72
73 =head1 METHODS
74
75 These methods are of little use to most users, they are used interally 
76 within L<MooseX::Getopt>.
77
78 =over 4
79
80 =item B<cmd_flag>
81
82 Changes the commandline flag to be this value, instead of the default,
83 which is the same as the attribute name.
84
85 =item B<cmd_aliases>
86
87 Adds more aliases for this commandline flag, useful for short options
88 and such.
89
90 =item B<has_cmd_flag>
91
92 =item B<has_cmd_aliases>
93
94 =item B<meta>
95
96 =back
97
98 =head1 BUGS
99
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
102 to cpan-RT.
103
104 =head1 AUTHOR
105
106 Stevan Little E<lt>stevan@iinteractive.comE<gt>
107
108 Brandon L. Black, E<lt>blblack@gmail.comE<gt>
109
110 =head1 COPYRIGHT AND LICENSE
111
112 Copyright 2007-2008 by Infinity Interactive, Inc.
113
114 L<http://www.iinteractive.com>
115
116 This library is free software; you can redistribute it and/or modify
117 it under the same terms as Perl itself.
118
119 =cut