From: Matt S Trout Date: Tue, 15 Nov 2011 07:18:06 +0000 (+0000) Subject: $client in tak repl X-Git-Tag: v0.001002~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=71be58607e0088aeb6ac6c0b07418a43b46e6aa5;p=scpubgit%2FTak.git $client in tak repl --- diff --git a/Changes b/Changes index 640da79..26974f5 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,4 @@ + - Provide a $client in repl objects - Support for -l/--local in Tak::Script 0.001001 - 2011-11-15 diff --git a/lib/Tak/EvalService.pm b/lib/Tak/EvalService.pm index 629beae..70b663d 100644 --- a/lib/Tak/EvalService.pm +++ b/lib/Tak/EvalService.pm @@ -9,8 +9,15 @@ with 'Tak::Role::Service'; has 'eval_withlexicals' => (is => 'lazy'); +has 'service_client' => (is => 'ro', predicate => 'has_service_client'); + sub _build_eval_withlexicals { - Eval::WithLexicals->new + my ($self) = @_; + Eval::WithLexicals->new( + $self->has_service_client + ? (lexicals => { '$client' => \($self->service_client) }) + : () + ); } sub handle_eval { diff --git a/lib/Tak/Role/ScriptActions.pm b/lib/Tak/Role/ScriptActions.pm index 9551b62..2d4a23a 100644 --- a/lib/Tak/Role/ScriptActions.pm +++ b/lib/Tak/Role/ScriptActions.pm @@ -59,7 +59,10 @@ sub each_repl (I=s@;m=s@;M=s@) { my ($self, $remote, $options) = @_; require Tak::REPL; require B; - $remote->ensure(eval_service => 'Tak::EvalService'); + $remote->ensure( + eval_service => 'Tak::EvalService', + expose => { service_client => [ '' ] }, + ); foreach my $lib (@{$options->{'I'}||[]}) { $remote->do(eval_service => eval => "lib->import(${\B::perlstring($lib)})"); }