f52eb316617ca89b555ba40d4778985de7dae321
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / Peek.pm
1 use strict;
2 use warnings;
3 package Devel::REPL::Plugin::Peek;
4
5 use Devel::REPL::Plugin;
6 use Devel::Peek qw(Dump);
7 use namespace::autoclean;
8
9 sub BEFORE_PLUGIN {
10     my $self = shift;
11     $self->load_plugin('Turtles');
12 }
13
14 sub expr_command_peek {
15   my ( $self, $eval, $code ) = @_;
16
17   my @res = $self->eval($code);
18
19   if ( $self->is_error(@res) ) {
20     return $self->format(@res);
21   } else {
22     # can't override output properly
23     # FIXME do some dup wizardry
24     Dump(@res);
25     return ""; # this is a hack to print nothing after Dump has already printed. PLZ TO FIX KTHX!
26   }
27 }
28
29 __PACKAGE__
30
31 __END__
32
33 =pod
34
35 =head1 NAME
36
37 Devel::REPL::Plugin::Peek - L<Devel::Peek> plugin for L<Devel::REPL>.
38
39 =head1 SYNOPSIS
40
41   repl> #peek "foo"
42   SV = PV(0xb3dba0) at 0xb4abc0
43     REFCNT = 1
44     FLAGS = (POK,READONLY,pPOK)
45     PV = 0x12bcf70 "foo"\0
46     CUR = 3
47     LEN = 4
48
49 =head1 DESCRIPTION
50
51 This L<Devel::REPL::Plugin> adds a C<peek> command that calls
52 L<Devel::Peek/Dump> instead of the normal printing.
53
54 =head1 SEE ALSO
55
56 L<Devel::REPL>, L<Devel::Peek>
57
58 =head1 AUTHOR
59
60 Yuval Kogman E<lt>nothingmuch@woobling.orgE<gt>
61
62 =cut