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