line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package oCLI::Plugin; |
2
|
1
|
|
|
1
|
|
10
|
use Moo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
13
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
has plugins => ( |
5
|
|
|
|
|
|
|
is => 'rw', |
6
|
|
|
|
|
|
|
default => sub { return [] }, |
7
|
|
|
|
|
|
|
); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub add { |
10
|
0
|
|
|
0
|
0
|
|
my ( $self, $plugin ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
push @{$self->plugins}, $plugin; |
|
0
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub hook_after_context { |
16
|
0
|
|
|
0
|
0
|
|
my ( $self, $c ) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
foreach my $plugin ( @{$self->plugins} ) { |
|
0
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
$plugin->after_context($c); |
20
|
|
|
|
|
|
|
} |
21
|
0
|
|
|
|
|
|
return; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub hook_before_code { |
25
|
0
|
|
|
0
|
0
|
|
my ( $self, $c, $command ) = @_; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
foreach my $plugin ( @{$self->plugins} ) { |
|
0
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$plugin->before_code($c, $command); |
29
|
|
|
|
|
|
|
} |
30
|
0
|
|
|
|
|
|
return; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub hook_after_code { |
34
|
0
|
|
|
0
|
0
|
|
my ( $self, $c ) = @_; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
foreach my $plugin ( @{$self->plugins} ) { |
|
0
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
$plugin->after_code($c); |
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
|
|
|
|
return; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |