634bbbb2bb52aadccbe8cd32a16a5d970fefc8c9
[gitmo/MooseX-Getopt.git] / lib / MooseX / Getopt / Meta / Attribute.pm
1
2 package MooseX::Getopt::Meta::Attribute;
3 use Moose;
4
5 our $VERSION   = '0.01';
6 our $AUTHORITY = 'cpan:STEVAN';
7
8 extends 'Moose::Meta::Attribute'; # << Moose extending Moose :)
9
10 has 'cmd_flag' => (
11     is        => 'rw',
12     isa       => 'Str',
13     predicate => 'has_cmd_flag',
14 );
15
16 has 'cmd_aliases' => (
17     is        => 'rw',
18     isa       => 'ArrayRef',
19     predicate => 'has_cmd_aliases',
20 );
21
22 no Moose; 1;
23
24 __END__
25
26
27 =pod
28
29 =head1 NAME
30
31 MooseX::Getopt::Meta::Attribute - Optional meta attribute for custom option names
32
33 =head1 SYNOPSIS
34
35   package App;
36   use Moose;
37   
38   with 'MooseX::Getopt';
39   
40   has 'data' => (
41       metaclass => 'MooseX::Getopt::Meta::Attribute',        
42       is        => 'ro',
43       isa       => 'Str',
44       default   => 'file.dat',
45       # tells MooseX::Getopt to use --somedata as the 
46       # command line flag instead of the normal 
47       # autogenerated one (--data)
48       cmd_flag  => 'somedata',
49       # tells MooseX::Getopt to also allow --moosedata,
50       # -m, and -d as aliases for this same option on
51       # the commandline.
52       cmd_aliases => [qw/ moosedata m d /],
53   );
54
55 =head1 DESCRIPTION
56
57 This is a custom attribute metaclass which can be used to specify a 
58 the specific command line flag to use instead of the default one 
59 which L<MooseX::Getopt> will create for you. 
60
61 This is certainly not the prettiest way to go about this, but for 
62 now it works for those who might need such a feature.
63
64 =head1 METHODS
65
66 These methods are of little use to most users, they are used interally 
67 within L<MooseX::Getopt>.
68
69 =over 4
70
71 =item B<cmd_flag>
72
73 Changes the commandline flag to be this value, instead of the default,
74 which is the same as the attribute name.
75
76 =item B<cmd_aliases>
77
78 Adds more aliases for this commandline flag, useful for short options
79 and such.
80
81 =item B<has_cmd_flag>
82
83 =item B<has_cmd_aliases>
84
85 =item B<meta>
86
87 =back
88
89 =head1 BUGS
90
91 All complex software has bugs lurking in it, and this module is no 
92 exception. If you find a bug please either email me, or add the bug
93 to cpan-RT.
94
95 =head1 AUTHOR
96
97 Stevan Little E<lt>stevan@iinteractive.comE<gt>
98
99 =head1 COPYRIGHT AND LICENSE
100
101 Copyright 2007 by Infinity Interactive, Inc.
102
103 L<http://www.iinteractive.com>
104
105 This library is free software; you can redistribute it and/or modify
106 it under the same terms as Perl itself.
107
108 =cut