| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
24387
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
23
|
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
23
|
|
|
3
|
1
|
|
|
1
|
|
18
|
use 5.010; |
|
|
1
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package MyApp; |
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
762
|
use MooseX::App qw/ Color BashCompletion ZshCompletion /; |
|
|
1
|
|
|
|
|
1036926
|
|
|
|
1
|
|
|
|
|
6
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
option 'verbose' => ( |
|
10
|
|
|
|
|
|
|
is => 'rw', |
|
11
|
|
|
|
|
|
|
isa => 'Bool', |
|
12
|
|
|
|
|
|
|
documentation => q[be verbose], |
|
13
|
|
|
|
|
|
|
); # Global option |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'private' => ( |
|
16
|
|
|
|
|
|
|
is => 'rw', |
|
17
|
|
|
|
|
|
|
); # not exposed |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package MyApp::FetchMail; |
|
20
|
1
|
|
|
1
|
|
247198
|
use MooseX::App::Command; # important (also imports Moose) |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
9
|
|
|
21
|
|
|
|
|
|
|
extends qw(MyApp); # optional, only if you want to use global options from base class |
|
22
|
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
11552
|
use Moose::Util::TypeConstraints; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
10
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
enum 'MailserverType', [qw(IMAP POP3)]; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Positional parameter |
|
28
|
|
|
|
|
|
|
parameter 'server' => ( |
|
29
|
|
|
|
|
|
|
is => 'rw', |
|
30
|
|
|
|
|
|
|
isa => 'Str', |
|
31
|
|
|
|
|
|
|
required => 1, |
|
32
|
|
|
|
|
|
|
documentation => q[Mailserver], |
|
33
|
|
|
|
|
|
|
); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
option 'servertype' => ( |
|
36
|
|
|
|
|
|
|
is => 'rw', |
|
37
|
|
|
|
|
|
|
isa => 'MailserverType', |
|
38
|
|
|
|
|
|
|
required => 1, |
|
39
|
|
|
|
|
|
|
documentation => q[Mailserver type: IMAP or POP3], |
|
40
|
|
|
|
|
|
|
); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
option 'max' => ( |
|
43
|
|
|
|
|
|
|
is => 'rw', |
|
44
|
|
|
|
|
|
|
isa => 'Int', |
|
45
|
|
|
|
|
|
|
required => 1, |
|
46
|
|
|
|
|
|
|
documentation => q[Maximum number of emails to fetch], |
|
47
|
|
|
|
|
|
|
); # Option |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
option 'dir' => ( |
|
50
|
|
|
|
|
|
|
is => 'rw', |
|
51
|
|
|
|
|
|
|
isa => 'Str', |
|
52
|
|
|
|
|
|
|
required => 0, |
|
53
|
|
|
|
|
|
|
documentation => q[Output 'dir'], |
|
54
|
|
|
|
|
|
|
); # Option |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
option 'user' => ( |
|
57
|
|
|
|
|
|
|
is => 'rw', |
|
58
|
|
|
|
|
|
|
isa => 'Str', |
|
59
|
|
|
|
|
|
|
required => 1, |
|
60
|
|
|
|
|
|
|
documentation => q[User], |
|
61
|
|
|
|
|
|
|
); # Option |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub run { |
|
64
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
65
|
|
|
|
|
|
|
# Do something |
|
66
|
0
|
|
|
|
|
|
my $server = $self->server; |
|
67
|
0
|
|
|
|
|
|
my $max = $self->max; |
|
68
|
0
|
0
|
|
|
|
|
if ($self->verbose) { |
|
69
|
0
|
|
|
|
|
|
say "Connecting to $server..."; |
|
70
|
0
|
|
|
|
|
|
say "Fetching up to $max emails..."; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
0
|
|
|
|
|
|
my $count = int rand 150; |
|
73
|
0
|
0
|
|
|
|
|
$count = $max if $count >= $max; |
|
74
|
0
|
|
|
|
|
|
say "Fetched $count emails"; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
package MyApp::Lala; |
|
78
|
1
|
|
|
1
|
|
2273
|
use MooseX::App::Command; # important (also imports Moose) |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
5
|
|
|
79
|
|
|
|
|
|
|
extends qw(MyApp); # optional, only if you want to use global options from base class |
|
80
|
|
|
|
|
|
|
|
|
81
|
1
|
|
|
1
|
|
11446
|
use Moose::Util::TypeConstraints; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
enum 'FooBar', [qw(foo bar boo)]; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
parameter 'bar' => ( |
|
86
|
|
|
|
|
|
|
is => 'rw', |
|
87
|
|
|
|
|
|
|
isa => 'FooBar', |
|
88
|
|
|
|
|
|
|
required => 1, |
|
89
|
|
|
|
|
|
|
cmd_position => 2, |
|
90
|
|
|
|
|
|
|
documentation => q[bar], |
|
91
|
|
|
|
|
|
|
); |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
parameter 'boo' => ( |
|
94
|
|
|
|
|
|
|
is => 'rw', |
|
95
|
|
|
|
|
|
|
isa => 'FooBar', |
|
96
|
|
|
|
|
|
|
required => 1, |
|
97
|
|
|
|
|
|
|
cmd_position => 3, |
|
98
|
|
|
|
|
|
|
documentation => q[boo], |
|
99
|
|
|
|
|
|
|
); |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
parameter 'foo' => ( |
|
102
|
|
|
|
|
|
|
is => 'rw', |
|
103
|
|
|
|
|
|
|
isa => 'FooBar', |
|
104
|
|
|
|
|
|
|
required => 1, |
|
105
|
|
|
|
|
|
|
cmd_position => 1, |
|
106
|
|
|
|
|
|
|
documentation => q[foo], |
|
107
|
|
|
|
|
|
|
); |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub run { |
|
111
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
112
|
0
|
|
|
|
|
|
say sprintf "foo: %s, bar:%s, boo: %s", $self->foo, $self->bar, $self->boo; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |