Skip to content

Commit f4d019b

Browse files
sorearPerl 6 Evalbot
authored andcommitted
Enable command-line testing of p6eval changes
1 parent 9758de2 commit f4d019b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

evalbot.pl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,22 @@ package Evalbot;
315315
package main;
316316

317317
my $config_file = shift @ARGV
318-
or confess("Usage: $0 <config_file>");
318+
or confess("Usage: $0 <config_file>\n or: $0 -run <impl> <code>");
319+
320+
if ($config_file eq '-run') {
321+
my ($eval_name, $str) = @ARGV;
322+
my $e = $Evalbot::impls{$eval_name};
323+
die("No such implementation.\n") unless $e;
324+
my $result = EvalbotExecuter::run($str, $e, $eval_name);
325+
my $revision = '';
326+
if (Scalar::Util::reftype($e) eq 'HASH' && $e->{revision}){
327+
$revision = ' ' . $e->{revision}->();
328+
}
329+
binmode STDOUT, ':utf8';
330+
printf "%s%s: %s\n", $eval_name, $revision, $result;
331+
exit 0;
332+
}
333+
319334
my %conf = %{ Config::File::read_config_file($config_file) };
320335

321336
#warn Dumper(\%conf);

0 commit comments

Comments
 (0)