Commit | Line | Data |
5dac17c3 |
1 | |
23575d46 |
2 | package MooseX::Getopt::Meta::Attribute; |
5dac17c3 |
3 | use Moose; |
61c9baa9 |
4 | use Moose::Util::TypeConstraints; |
5dac17c3 |
5 | |
5f905015 |
6 | our $VERSION = '0.25'; |
8034a232 |
7 | our $AUTHORITY = 'cpan:STEVAN'; |
8 | |
9 | extends 'Moose::Meta::Attribute'; # << Moose extending Moose :) |
adbe3e57 |
10 | with 'MooseX::Getopt::Meta::Attribute::Trait'; |
de75868f |
11 | |
1a8b4ed1 |
12 | no Moose; |
5dac17c3 |
13 | |
1a8b4ed1 |
14 | # register this as a metaclass alias ... |
6ac028c4 |
15 | package # stop confusing PAUSE |
16 | Moose::Meta::Attribute::Custom::Getopt; |
1a8b4ed1 |
17 | sub register_implementation { 'MooseX::Getopt::Meta::Attribute' } |
18 | |
19 | 1; |
5dac17c3 |
20 | |
1a8b4ed1 |
21 | __END__ |
5dac17c3 |
22 | |
23 | =pod |
24 | |
25 | =head1 NAME |
26 | |
8034a232 |
27 | MooseX::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 |
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 | |
1a8b4ed1 |
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 | |
5dac17c3 |
73 | =head1 METHODS |
74 | |
8034a232 |
75 | These methods are of little use to most users, they are used interally |
76 | within L<MooseX::Getopt>. |
77 | |
5dac17c3 |
78 | =over 4 |
79 | |
80 | =item B<cmd_flag> |
81 | |
de75868f |
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 | |
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 | |
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 | |
3d9a716d |
108 | Brandon L. Black, E<lt>blblack@gmail.comE<gt> |
109 | |
5dac17c3 |
110 | =head1 COPYRIGHT AND LICENSE |
111 | |
adbe3e57 |
112 | Copyright 2007-2008 by Infinity Interactive, Inc. |
5dac17c3 |
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 | |
de75868f |
119 | =cut |