line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ============================================================================ |
2
|
|
|
|
|
|
|
package MooseX::App::Role; |
3
|
|
|
|
|
|
|
# ============================================================================ |
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
6534
|
use 5.010; |
|
9
|
|
|
|
|
37
|
|
6
|
9
|
|
|
9
|
|
53
|
use utf8; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
50
|
|
7
|
9
|
|
|
9
|
|
242
|
use strict; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
200
|
|
8
|
9
|
|
|
9
|
|
48
|
use warnings; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
290
|
|
9
|
|
|
|
|
|
|
|
10
|
9
|
|
|
9
|
|
55
|
use Moose::Role (); |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
350
|
|
11
|
9
|
|
|
9
|
|
62
|
use MooseX::App::Exporter qw(option parameter); |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
90
|
|
12
|
9
|
|
|
9
|
|
76
|
use Moose::Exporter; |
|
9
|
|
|
|
|
26
|
|
|
9
|
|
|
|
|
159
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Moose::Exporter->setup_import_methods( |
15
|
|
|
|
|
|
|
also => 'Moose::Role', |
16
|
|
|
|
|
|
|
with_meta => [qw(option parameter)], |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init_meta { |
20
|
9
|
|
|
9
|
0
|
1015
|
my (undef,%args) = @_; |
21
|
|
|
|
|
|
|
|
22
|
9
|
|
|
|
|
52
|
my $meta = Moose::Role->init_meta( %args ); |
23
|
|
|
|
|
|
|
|
24
|
9
|
|
|
|
|
12068
|
Moose::Util::MetaRole::apply_metaroles( |
25
|
|
|
|
|
|
|
for => $meta, |
26
|
|
|
|
|
|
|
role_metaroles => { |
27
|
|
|
|
|
|
|
applied_attribute => ['MooseX::App::Meta::Role::Attribute::Option'], |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
9
|
|
|
|
|
33895
|
return $meta; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=pod |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 NAME |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
MooseX::App::Role - Define attributes in a role |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
package MyApp::Role::SomeRole; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
use MooseX::App::Role; # Alo loads Moose::Role |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
option 'testattr' => ( |
51
|
|
|
|
|
|
|
isa => 'rw', |
52
|
|
|
|
|
|
|
cmd_tags => [qw(Important! Nice))], |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 DESCRIPTION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Enables the 'option' and 'parameter' keywords in your roles. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Alternatively you can also just use attribute traits: |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
has 'testattr' => ( |
62
|
|
|
|
|
|
|
isa => 'rw', |
63
|
|
|
|
|
|
|
traits => ['AppOption'], # required |
64
|
|
|
|
|
|
|
cmd_type => 'option', # required |
65
|
|
|
|
|
|
|
cmd_tags => [qw(Important! Nice))], |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |