unify version numbers
[gitmo/MooseX-Getopt.git] / lib / MooseX / Getopt / Meta / Attribute.pm
CommitLineData
5dac17c3 1
23575d46 2package MooseX::Getopt::Meta::Attribute;
5dac17c3 3use Moose;
61c9baa9 4use Moose::Util::TypeConstraints;
5dac17c3 5
091954ec 6our $VERSION = '0.17';
8034a232 7our $AUTHORITY = 'cpan:STEVAN';
8
9extends 'Moose::Meta::Attribute'; # << Moose extending Moose :)
adbe3e57 10 with 'MooseX::Getopt::Meta::Attribute::Trait';
de75868f 11
1a8b4ed1 12no Moose;
5dac17c3 13
1a8b4ed1 14# register this as a metaclass alias ...
6ac028c4 15package # stop confusing PAUSE
16 Moose::Meta::Attribute::Custom::Getopt;
1a8b4ed1 17sub register_implementation { 'MooseX::Getopt::Meta::Attribute' }
18
191;
5dac17c3 20
1a8b4ed1 21__END__
5dac17c3 22
23=pod
24
25=head1 NAME
26
8034a232 27MooseX::Getopt::Meta::Attribute - Optional meta attribute for custom option names
5dac17c3 28
29=head1 SYNOPSIS
30
8034a232 31 package App;
32 use Moose;
33
34 with 'MooseX::Getopt';
35
36 has 'data' => (
1a8b4ed1 37 metaclass => 'MooseX::Getopt::Meta::Attribute',
8034a232 38 is => 'ro',
39 isa => 'Str',
40 default => 'file.dat',
61c9baa9 41
de75868f 42 # tells MooseX::Getopt to use --somedata as the
8034a232 43 # command line flag instead of the normal
44 # autogenerated one (--data)
de75868f 45 cmd_flag => 'somedata',
61c9baa9 46
de75868f 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 /],
61c9baa9 51
52 # Or, you can use a plain scalar for a single alias:
53 cmd_aliases => 'm',
8034a232 54 );
55
5dac17c3 56=head1 DESCRIPTION
57
8034a232 58This is a custom attribute metaclass which can be used to specify a
59the specific command line flag to use instead of the default one
60which L<MooseX::Getopt> will create for you.
61
62This is certainly not the prettiest way to go about this, but for
63now it works for those who might need such a feature.
64
1a8b4ed1 65=head2 Custom Metaclass alias
66
67This now takes advantage of the Moose 0.19 feature to support
68custom attribute metaclass aliases. This means you can also
69use this as the B<Getopt> alias, like so:
70
71 has 'foo' => (metaclass => 'Getopt', cmd_flag => 'f');
72
5dac17c3 73=head1 METHODS
74
8034a232 75These methods are of little use to most users, they are used interally
76within L<MooseX::Getopt>.
77
5dac17c3 78=over 4
79
80=item B<cmd_flag>
81
de75868f 82Changes the commandline flag to be this value, instead of the default,
83which is the same as the attribute name.
84
85=item B<cmd_aliases>
86
87Adds more aliases for this commandline flag, useful for short options
88and such.
89
5dac17c3 90=item B<has_cmd_flag>
91
de75868f 92=item B<has_cmd_aliases>
93
5dac17c3 94=item B<meta>
95
96=back
97
98=head1 BUGS
99
100All complex software has bugs lurking in it, and this module is no
101exception. If you find a bug please either email me, or add the bug
102to cpan-RT.
103
104=head1 AUTHOR
105
106Stevan Little E<lt>stevan@iinteractive.comE<gt>
107
3d9a716d 108Brandon L. Black, E<lt>blblack@gmail.comE<gt>
109
5dac17c3 110=head1 COPYRIGHT AND LICENSE
111
adbe3e57 112Copyright 2007-2008 by Infinity Interactive, Inc.
5dac17c3 113
114L<http://www.iinteractive.com>
115
116This library is free software; you can redistribute it and/or modify
117it under the same terms as Perl itself.
118
de75868f 119=cut