line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MouseX::Getopt::Meta::Attribute; |
2
|
|
|
|
|
|
|
# ABSTRACT: Optional meta attribute for custom option names |
3
|
|
|
|
|
|
|
|
4
|
22
|
|
|
22
|
|
80
|
use Mouse; |
|
22
|
|
|
|
|
22
|
|
|
22
|
|
|
|
|
83
|
|
5
|
22
|
|
|
22
|
|
4476
|
use Mouse::Util::TypeConstraints; |
|
22
|
|
|
|
|
29
|
|
|
22
|
|
|
|
|
90
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'Mouse::Meta::Attribute'; # << Mouse extending Mouse :) |
8
|
|
|
|
|
|
|
with 'MouseX::Getopt::Meta::Attribute::Trait'; |
9
|
|
|
|
|
|
|
|
10
|
22
|
|
|
22
|
|
1709
|
no Mouse; |
|
22
|
|
|
|
|
26
|
|
|
22
|
|
|
|
|
61
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# register this as a metaclass alias ... |
13
|
|
|
|
|
|
|
package # stop confusing PAUSE |
14
|
|
|
|
|
|
|
Mouse::Meta::Attribute::Custom::Getopt; |
15
|
5
|
|
|
5
|
|
5101
|
sub register_implementation { 'MouseX::Getopt::Meta::Attribute' } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
1; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=for stopwords metaclass commandline params configfile |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package App; |
24
|
|
|
|
|
|
|
use Mouse; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
with 'MouseX::Getopt'; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has 'data' => ( |
29
|
|
|
|
|
|
|
metaclass => 'MouseX::Getopt::Meta::Attribute', |
30
|
|
|
|
|
|
|
is => 'ro', |
31
|
|
|
|
|
|
|
isa => 'Str', |
32
|
|
|
|
|
|
|
default => 'file.dat', |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# tells MouseX::Getopt to use --somedata as the |
35
|
|
|
|
|
|
|
# command line flag instead of the normal |
36
|
|
|
|
|
|
|
# autogenerated one (--data) |
37
|
|
|
|
|
|
|
cmd_flag => 'somedata', |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# tells MouseX::Getopt to also allow --moosedata, |
40
|
|
|
|
|
|
|
# -m, and -d as aliases for this same option on |
41
|
|
|
|
|
|
|
# the commandline. |
42
|
|
|
|
|
|
|
cmd_aliases => [qw/ moosedata m d /], |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Or, you can use a plain scalar for a single alias: |
45
|
|
|
|
|
|
|
cmd_aliases => 'm', |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This is a custom attribute metaclass which can be used to specify a |
51
|
|
|
|
|
|
|
the specific command line flag to use instead of the default one |
52
|
|
|
|
|
|
|
which L will create for you. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This is certainly not the prettiest way to go about this, but for |
55
|
|
|
|
|
|
|
now it works for those who might need such a feature. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 Custom Metaclass alias |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This now takes advantage of the Moose 0.19 feature to support |
60
|
|
|
|
|
|
|
custom attribute metaclass aliases. This means you can also |
61
|
|
|
|
|
|
|
use this as the B alias, like so: |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has 'foo' => (metaclass => 'Getopt', cmd_flag => 'f'); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=over 4 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item B |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Changes the commandline flag to be this value, instead of the default, |
70
|
|
|
|
|
|
|
which is the same as the attribute name. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item B |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Adds more aliases for this commandline flag, useful for short options |
75
|
|
|
|
|
|
|
and such. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item B |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item B |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=back |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |