r61423@onn: sartak | 2008-06-02 16:00:33 -0400
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / B / Concise.pm
index b065b60..2965d9c 100644 (file)
@@ -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<concise> command that uses L<B::Concise> to dump
 optrees of expressions.
 
 The code is not actually executed, which means that when used with
-L<Deve::REPL::Plugin::OutputCache> there is .
+L<Deve::REPL::Plugin::OutputCache> there is no new value in C<_>.
 
 The command takes the same options as L<B::Concise/compile>, e.g. C<-basic> or
 C<-exec> to determine the dump order, C<-debug>, C<-concise> and C<-terse> to