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