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