line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
16
|
|
|
16
|
|
14352
|
use 5.010001; |
|
16
|
|
|
|
|
66
|
|
2
|
16
|
|
|
16
|
|
129
|
use strict; |
|
16
|
|
|
|
|
32
|
|
|
16
|
|
|
|
|
464
|
|
3
|
16
|
|
|
16
|
|
98
|
use warnings; |
|
16
|
|
|
|
|
45
|
|
|
16
|
|
|
|
|
899
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Mite::App::Command::exec; |
6
|
16
|
|
|
16
|
|
138
|
use Mite::Miteception -all; |
|
16
|
|
|
|
|
65
|
|
|
16
|
|
|
|
|
158
|
|
7
|
|
|
|
|
|
|
extends qw(Mite::App::Command); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
10
|
|
|
|
|
|
|
our $VERSION = '0.012000'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub abstract { |
13
|
16
|
|
|
16
|
0
|
88
|
return "Compile the project in memory and run a script."; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
around _build_kingpin_command => sub { |
17
|
|
|
|
|
|
|
my ( $next, $self, @args ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $command = $self->$next( @args ); |
20
|
|
|
|
|
|
|
$command->flag( 'oneliner', 'Script is a oneliner, not a filename.' )->short( 'e' )->bool; |
21
|
|
|
|
|
|
|
$command->arg( 'script', 'Script to run.' )->file; |
22
|
|
|
|
|
|
|
$command->arg( 'args', 'Arguments to pass to script.' )->string_list; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
return $command; |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub execute { |
28
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
29
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
return 0 if $self->should_exit_quietly; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my $oneliner = $self->kingpin_command->flags->get( 'oneliner' )->value; |
33
|
0
|
|
|
|
|
|
my $script = $self->kingpin_command->args->get( 'script' )->value; |
34
|
0
|
|
|
|
|
|
my $args = $self->kingpin_command->args->get( 'args' )->value; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
unless ( defined $script ) { |
37
|
0
|
|
|
|
|
|
printf STDERR "%s: error: expected oneliner or script, try --help\n", |
38
|
|
|
|
|
|
|
$self->kingpin_command->parent->name; |
39
|
0
|
|
|
|
|
|
return 1; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $project = $self->project; |
43
|
0
|
|
|
|
|
|
$project->load_directory; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
for my $source ( values %{ $project->sources } ) { |
|
0
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
local $@; |
47
|
0
|
0
|
|
|
|
|
eval( $source->compile ) or die $@; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
{ |
51
|
0
|
0
|
|
|
|
|
local @ARGV = @{ $args || [] }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
if ( $oneliner ) { |
53
|
0
|
|
|
|
|
|
local $@; |
54
|
0
|
|
|
|
|
|
my $r = eval "$script; 1"; |
55
|
0
|
0
|
|
|
|
|
if ( $r ) { |
56
|
0
|
|
|
|
|
|
return 0; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
0
|
|
|
|
|
|
warn "$@\n"; |
60
|
0
|
|
|
|
|
|
return 1; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
else { |
64
|
0
|
0
|
|
|
|
|
if ( not $script->exists ) { |
65
|
0
|
|
|
|
|
|
printf STDERR "%s: error: %s does not exist, try --help\n", |
66
|
|
|
|
|
|
|
$self->kingpin_command->parent->name, $script; |
67
|
0
|
|
|
|
|
|
return 1; |
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
|
local $@; |
70
|
0
|
|
|
|
|
|
do $script; |
71
|
0
|
0
|
|
|
|
|
if ( $@ ) { |
72
|
0
|
|
|
|
|
|
warn "$@\n"; |
73
|
0
|
|
|
|
|
|
return 1; |
74
|
|
|
|
|
|
|
} |
75
|
0
|
|
|
|
|
|
return 0; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return 0; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |