line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ============================================================================ |
2
|
|
|
|
|
|
|
package MooseX::App::Role; |
3
|
|
|
|
|
|
|
# ============================================================================ |
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
4517
|
use 5.010; |
|
9
|
|
|
|
|
23
|
|
6
|
9
|
|
|
9
|
|
66
|
use utf8; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
54
|
|
7
|
9
|
|
|
9
|
|
217
|
use strict; |
|
9
|
|
|
|
|
12
|
|
|
9
|
|
|
|
|
201
|
|
8
|
9
|
|
|
9
|
|
39
|
use warnings; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
272
|
|
9
|
|
|
|
|
|
|
|
10
|
9
|
|
|
9
|
|
35
|
use Moose::Role (); |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
207
|
|
11
|
9
|
|
|
9
|
|
46
|
use MooseX::App::Exporter qw(option parameter); |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
87
|
|
12
|
9
|
|
|
9
|
|
47
|
use Moose::Exporter; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
67
|
|
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
|
762
|
my (undef,%args) = @_; |
21
|
|
|
|
|
|
|
|
22
|
9
|
|
|
|
|
49
|
my $meta = Moose::Role->init_meta( %args ); |
23
|
|
|
|
|
|
|
|
24
|
9
|
|
|
|
|
8438
|
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
|
|
|
|
|
29518
|
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 |