print a warning when Completion is loaded but the Term::ReadLine object doesn't suppo...
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / Turtles.pm
CommitLineData
e958cbc6 1package Devel::REPL::Plugin::Turtles;
2use Moose::Role;
48ddfeae 3use namespace::clean -except => [ 'meta' ];
e958cbc6 4
5around 'eval' => sub {
0cbfa921 6 my $next = shift;
7 my ($self, $line) = @_;
8 if ( my ( $command, $rest ) = ( $line =~ /^#(\w+)\s*(.*)/ ) ) {
9 if ( my $cont = $self->can("continue_reading_if_necessary") ) {
10 $rest = $self->$cont($rest);
e958cbc6 11 }
0cbfa921 12
13 my $method = "command_$command";
14
15 if ( $self->can($method) ) {
16 return $self->$method($rest);
17 } else {
18 return $self->error_return("REPL error", "Command '$command' does not exist");
e958cbc6 19 }
0cbfa921 20 }
21 else {
22 return $next->($self, $line);
23 }
e958cbc6 24};
25
48ddfeae 261;