X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-REPL.git;a=blobdiff_plain;f=lib%2FDevel%2FREPL%2FPlugin%2FPeek.pm;h=fbc57dbd20a03ef217ec5c68d4ae6ee1deb4f0b0;hp=e6f48935bbf24feca9782c7950ee1510cadc8943;hb=c45376f3de16a5a467a1a26e63a279f30eb8672d;hpb=1c4d0148a1b0121cdfee1f3bd97631289a524d09 diff --git a/lib/Devel/REPL/Plugin/Peek.pm b/lib/Devel/REPL/Plugin/Peek.pm index e6f4893..fbc57db 100644 --- a/lib/Devel/REPL/Plugin/Peek.pm +++ b/lib/Devel/REPL/Plugin/Peek.pm @@ -1,26 +1,32 @@ -#!/usr/bin/perl - +use strict; +use warnings; package Devel::REPL::Plugin::Peek; -use Devel::REPL::Plugin; +# ABSTRACT: L plugin for L. -use Devel::Peek qw(Dump); +our $VERSION = '1.003029'; -use namespace::clean -except => [ 'meta' ]; +use Devel::REPL::Plugin; +use Devel::Peek qw(Dump); +use namespace::autoclean; -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__ @@ -29,10 +35,6 @@ __END__ =pod -=head1 NAME - -Devel::REPL::Plugin::Peek - L plugin for L. - =head1 SYNOPSIS repl> #peek "foo"