From 349c98a1077192fe7673e41f86ceb538b59b9a2f Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 26 Jun 2013 15:11:47 -0400 Subject: add a default command of #q for quitting the repl --- lib/Reply/Plugin/Defaults.pm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/Reply/Plugin/Defaults.pm b/lib/Reply/Plugin/Defaults.pm index 28d0557..2114e3f 100644 --- a/lib/Reply/Plugin/Defaults.pm +++ b/lib/Reply/Plugin/Defaults.pm @@ -15,6 +15,15 @@ use base 'Reply::Plugin'; use Eval::Closure; +sub new { + my $class = shift; + + my $self = $class->SUPER::new(@_); + $self->{quit} = 0; + + return $self; +} + sub prompt { "> " } sub read_line { @@ -79,4 +88,19 @@ sub print_result { if @result; } +sub command_q { + my $self = shift; + $self->{quit} = 1; + return ''; +} + +sub loop { + my $self = shift; + my ($continue) = @_; + + $continue = 0 if $self->{quit}; + + return $continue; +} + 1; -- cgit v1.2.3-54-g00ecf