line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MouseX::Getopt::Meta::Attribute::Trait; |
2
|
|
|
|
|
|
|
# ABSTRACT: Optional meta attribute trait for custom option names |
3
|
|
|
|
|
|
|
|
4
|
22
|
|
|
22
|
|
7673
|
use Mouse::Role; |
|
22
|
|
|
|
|
29
|
|
|
22
|
|
|
|
|
89
|
|
5
|
22
|
|
|
22
|
|
3570
|
use Mouse::Util::TypeConstraints; |
|
22
|
|
|
|
|
26
|
|
|
22
|
|
|
|
|
116
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'cmd_flag' => ( |
8
|
|
|
|
|
|
|
is => 'rw', |
9
|
|
|
|
|
|
|
isa => 'Str', |
10
|
|
|
|
|
|
|
predicate => 'has_cmd_flag', |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# This subtype is to support scalar -> arrayref coercion |
14
|
|
|
|
|
|
|
# without polluting the built-in types |
15
|
|
|
|
|
|
|
subtype '_MouseX_Getopt_CmdAliases' => as 'ArrayRef'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
coerce '_MouseX_Getopt_CmdAliases' |
18
|
|
|
|
|
|
|
=> from 'Str' |
19
|
|
|
|
|
|
|
=> via { [$_] }; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'cmd_aliases' => ( |
22
|
|
|
|
|
|
|
is => 'rw', |
23
|
|
|
|
|
|
|
isa => '_MouseX_Getopt_CmdAliases', |
24
|
|
|
|
|
|
|
predicate => 'has_cmd_aliases', |
25
|
|
|
|
|
|
|
coerce => 1, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
22
|
|
|
22
|
|
2450
|
no Mouse::Util::TypeConstraints; |
|
22
|
|
|
|
|
29
|
|
|
22
|
|
|
|
|
192
|
|
29
|
22
|
|
|
22
|
|
2165
|
no Mouse::Role; |
|
22
|
|
|
|
|
25
|
|
|
22
|
|
|
|
|
55
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# register this as a metaclass alias ... |
32
|
|
|
|
|
|
|
package # stop confusing PAUSE |
33
|
|
|
|
|
|
|
Mouse::Meta::Attribute::Custom::Trait::Getopt; |
34
|
20
|
|
|
20
|
|
8620
|
sub register_implementation { 'MouseX::Getopt::Meta::Attribute::Trait' } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=for stopwords metaclass commandline params configfile |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 SYNOPSIS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
package App; |
43
|
|
|
|
|
|
|
use Mouse; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
with 'MouseX::Getopt'; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has 'data' => ( |
48
|
|
|
|
|
|
|
traits => [ 'Getopt' ], |
49
|
|
|
|
|
|
|
is => 'ro', |
50
|
|
|
|
|
|
|
isa => 'Str', |
51
|
|
|
|
|
|
|
default => 'file.dat', |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# tells MouseX::Getopt to use --somedata as the |
54
|
|
|
|
|
|
|
# command line flag instead of the normal |
55
|
|
|
|
|
|
|
# autogenerated one (--data) |
56
|
|
|
|
|
|
|
cmd_flag => 'somedata', |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# tells MouseX::Getopt to also allow --moosedata, |
59
|
|
|
|
|
|
|
# -m, and -d as aliases for this same option on |
60
|
|
|
|
|
|
|
# the commandline. |
61
|
|
|
|
|
|
|
cmd_aliases => [qw/ moosedata m d /], |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Or, you can use a plain scalar for a single alias: |
64
|
|
|
|
|
|
|
cmd_aliases => 'm', |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DESCRIPTION |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This is a custom attribute metaclass trait which can be used to |
70
|
|
|
|
|
|
|
specify a the specific command line flag to use instead of the |
71
|
|
|
|
|
|
|
default one which L will create for you. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=over 4 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item B |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Changes the commandline flag to be this value, instead of the default, |
78
|
|
|
|
|
|
|
which is the same as the attribute name. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item B |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Adds more aliases for this commandline flag, useful for short options |
83
|
|
|
|
|
|
|
and such. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item B |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item B |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=back |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |