line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tak::REPL; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2633
|
use Term::ReadLine; |
|
1
|
|
|
|
|
2982
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
5
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has client => (is => 'ro', required => 1); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub run { |
9
|
0
|
|
|
0
|
0
|
|
my $client = $_[0]->client; |
10
|
0
|
|
|
|
|
|
my $read = Term::ReadLine->new('REPL'); |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
while (1) { |
13
|
0
|
|
|
|
|
|
my $line = $read->readline('re.pl$ '); |
14
|
0
|
0
|
|
|
|
|
last unless defined $line; |
15
|
0
|
0
|
|
|
|
|
next unless length $line; |
16
|
0
|
|
|
|
|
|
my $result = $client->do(eval => $line); |
17
|
0
|
0
|
|
|
|
|
print exists($result->{return}) |
18
|
|
|
|
|
|
|
? $result->{return} |
19
|
|
|
|
|
|
|
: "Error: ".$result->{exception}; |
20
|
0
|
0
|
|
|
|
|
if ($result->{stdout}) { |
21
|
0
|
|
|
|
|
|
chomp($result->{stdout}); |
22
|
0
|
|
|
|
|
|
print "STDOUT:\n${\$result->{stdout}}\n"; |
|
0
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
} |
24
|
0
|
0
|
|
|
|
|
if ($result->{stderr}) { |
25
|
0
|
|
|
|
|
|
chomp($result->{stderr}); |
26
|
0
|
|
|
|
|
|
print "STDERR:\n${\$result->{stderr}}\n"; |
|
0
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |