make room for $VERSION after package declaration (newer [PkgVersion] requires it)
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / Peek.pm
index e6f4893..f52eb31 100644 (file)
@@ -1,26 +1,29 @@
-#!/usr/bin/perl
-
+use strict;
+use warnings;
 package Devel::REPL::Plugin::Peek;
-use Devel::REPL::Plugin;
 
+use Devel::REPL::Plugin;
 use Devel::Peek qw(Dump);
+use namespace::autoclean;
 
-use namespace::clean -except => [ 'meta' ];
-
-with qw(Devel::REPL::Plugin::Turtles);
+sub BEFORE_PLUGIN {
+    my $self = shift;
+    $self->load_plugin('Turtles');
+}
 
 sub expr_command_peek {
   my ( $self, $eval, $code ) = @_;
 
-  if ( my $cont = $self->can("continue_reading_if_necessary") ) {
-    $code = $self->$cont($code);
-  }
-
-  # can't override output properly
-  # FIXME do some dup wizardry
-  Dump( $self->eval($code) );
+  my @res = $self->eval($code);
 
-  return ""; # this is a hack to print nothing after Dump has already printed. PLZ TO FIX KTHX!
+  if ( $self->is_error(@res) ) {
+    return $self->format(@res);
+  } else {
+    # can't override output properly
+    # FIXME do some dup wizardry
+    Dump(@res);
+    return ""; # this is a hack to print nothing after Dump has already printed. PLZ TO FIX KTHX!
+  }
 }
 
 __PACKAGE__