From: Matt S Trout Date: Fri, 11 Nov 2011 14:23:02 +0000 (+0000) Subject: enhance repl command X-Git-Tag: v0.001001~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FTak.git;a=commitdiff_plain;h=5c11b21f3091458cf787667ec338fb0a31a17027 enhance repl command --- diff --git a/lib/Tak/Role/ScriptActions.pm b/lib/Tak/Role/ScriptActions.pm index bde1cb7..9551b62 100644 --- a/lib/Tak/Role/ScriptActions.pm +++ b/lib/Tak/Role/ScriptActions.pm @@ -55,10 +55,25 @@ sub print_exec_result { } } -sub each_repl { - my ($self, $remote) = @_; +sub each_repl (I=s@;m=s@;M=s@) { + my ($self, $remote, $options) = @_; require Tak::REPL; + require B; $remote->ensure(eval_service => 'Tak::EvalService'); + foreach my $lib (@{$options->{'I'}||[]}) { + $remote->do(eval_service => eval => "lib->import(${\B::perlstring($lib)})"); + } + foreach my $module (@{$options->{'m'}||[]}) { + $remote->do(eval_service => eval => "use ${module} ()"); + } + foreach my $spec (@{$options->{'M'}||[]}) { + my ($module, $import) = split('=', $spec); + my $extra = ''; + if ($import) { + $extra = ' '.join(', ', map B::perlstring($_), split(',',$import)); + } + $remote->do(eval_service => eval => "use ${module}${extra}"); + } Tak::REPL->new(client => $remote->curry('eval_service'))->run; }