X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-REPL.git;a=blobdiff_plain;f=lib%2FDevel%2FREPL%2FPlugin%2FB%2FConcise.pm;h=2965d9cf9e480ab1fbddd91cf00f8f8ed5fbdc91;hp=b065b607d8d8a0c4c2595e4daa0f1c10985fe1b3;hb=3a40071593734bf02e987a076b6408095ecfad41;hpb=320b3ad545d61ea7a478021189f33e1d41192cba diff --git a/lib/Devel/REPL/Plugin/B/Concise.pm b/lib/Devel/REPL/Plugin/B/Concise.pm index b065b60..2965d9c 100644 --- a/lib/Devel/REPL/Plugin/B/Concise.pm +++ b/lib/Devel/REPL/Plugin/B/Concise.pm @@ -9,7 +9,10 @@ B::Concise::compileOpts(qw(-nobanner)); use namespace::clean -except => [ 'meta' ]; -with qw(Devel::REPL::Plugin::Turtles); +sub BEFORE_PLUGIN { + my $self = shift; + $self->load_plugin('Turtles'); +} sub AFTER_PLUGIN { my $self = shift; @@ -28,15 +31,21 @@ sub expr_command_concise { die unless $code; - my $sub = $self->compile($code, no_mangling => 1); + my %opts = map { $_ => 1 } (split /\s+/, $opts); - open my $fh, ">", \my $out; - { - local *STDOUT = $fh; - B::Concise::compile((split /\s+/, $opts), $sub)->(); - } + my $sub = $self->compile($code, no_mangling => !delete($opts{"-mangle"}) ); - return $out; + if ( $self->is_error($sub) ) { + return $self->format($sub); + } else { + open my $fh, ">", \my $out; + { + local *STDOUT = $fh; + B::Concise::compile(keys %opts, $sub)->(); + } + + return $out; + } } __PACKAGE__ @@ -69,7 +78,7 @@ This plugin provides a C command that uses L to dump optrees of expressions. The code is not actually executed, which means that when used with -L there is . +L there is no new value in C<_>. The command takes the same options as L, e.g. C<-basic> or C<-exec> to determine the dump order, C<-debug>, C<-concise> and C<-terse> to