line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archer::Plugin::Exec; |
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
6
|
use base qw/Archer::Plugin/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
537
|
|
5
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
69
|
|
6
|
1
|
|
|
1
|
|
1511
|
use Term::ANSIColor; |
|
1
|
|
|
|
|
15261
|
|
|
1
|
|
|
|
|
651
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub run { |
9
|
2
|
|
|
2
|
0
|
5
|
my ( $self, $context, $args ) = @_; |
10
|
2
|
|
|
|
|
3
|
my $cmd; |
11
|
|
|
|
|
|
|
|
12
|
2
|
50
|
|
|
|
16
|
if ( $self->{ config }->{ command } ) { |
|
|
0
|
|
|
|
|
|
13
|
2
|
|
|
|
|
6
|
$cmd = $self->{ config }->{ command }; |
14
|
2
|
|
|
|
|
19
|
$self->log( debug => "template: $cmd" ); |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
|
|
54
|
$cmd = $self->templatize( $cmd ); |
17
|
2
|
|
|
|
|
149
|
$self->log( info => "* execute " . colored( $cmd, 'red' ) ); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
elsif ( $self->{ config }->{ recipe } ) { |
20
|
|
|
|
|
|
|
#require Archer::Util; |
21
|
|
|
|
|
|
|
$cmd = $self->check_recipe( $self->{ config }->{ recipe }, |
22
|
0
|
|
|
|
|
0
|
$context->{ config }->{ global }->{ recipe } ); |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
|
|
|
0
|
if ( !defined $cmd ) { |
25
|
|
|
|
|
|
|
$self->log( |
26
|
0
|
|
|
|
|
0
|
'warn' => 'The recipe ' . $self->{ config }->{ recipe } . ' can\'t be found' |
27
|
|
|
|
|
|
|
); |
28
|
0
|
|
|
|
|
0
|
return; |
29
|
|
|
|
|
|
|
} |
30
|
0
|
|
|
|
|
0
|
$cmd = $self->templatize( $cmd ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
2
|
50
|
|
|
|
72
|
if ( $context->{ dry_run_fg } ) { |
34
|
0
|
|
|
|
|
0
|
$self->log( debug => "dry-run" ); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else { |
37
|
2
|
|
|
|
|
8
|
$self->log( debug => "run!" ); |
38
|
2
|
50
|
|
|
|
37
|
if ( $cmd ) { |
39
|
2
|
|
|
|
|
28
|
$self->_execute( $_ ) for grep !/^\s*$/, split /\n/, $cmd; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _execute { |
45
|
0
|
|
|
0
|
|
|
croak "this method is abstract"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
__END__ |