summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-06-26 15:11:47 -0400
committerJesse Luehrs <doy@tozt.net>2013-06-26 15:11:47 -0400
commit349c98a1077192fe7673e41f86ceb538b59b9a2f (patch)
treefef0d1acc7adfe7a34556a57b2d745297b16136b
parent1aadfc490b86be464b01069a6e5dcb521c4c6ebd (diff)
downloadreply-349c98a1077192fe7673e41f86ceb538b59b9a2f.tar.gz
reply-349c98a1077192fe7673e41f86ceb538b59b9a2f.zip
add a default command of #q for quitting the repl
-rw-r--r--lib/Reply/Plugin/Defaults.pm24
1 files changed, 24 insertions, 0 deletions
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;