summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-05-30 07:02:48 -0500
committerJesse Luehrs <doy@tozt.net>2013-05-30 07:02:48 -0500
commita3dcdb0d05d46a48e9305a34c4d4e0b954d50d9b (patch)
treef18ccd90f85ba40695769c36b4ee720a957fc05a
parentcdb35b5ad4803d8c02788bd7bbec2a678d124b75 (diff)
downloadreply-a3dcdb0d05d46a48e9305a34c4d4e0b954d50d9b.tar.gz
reply-a3dcdb0d05d46a48e9305a34c4d4e0b954d50d9b.zip
add a hook for the end of a cycle
-rw-r--r--lib/Reply.pm9
-rw-r--r--lib/Reply/Plugin/FancyPrompt.pm7
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/Reply.pm b/lib/Reply.pm
index 66ef8a4..699e808 100644
--- a/lib/Reply.pm
+++ b/lib/Reply.pm
@@ -94,7 +94,8 @@ sub run {
}
catch {
$self->_print_error($_);
- }
+ };
+ $self->_loop;
}
print "\n";
}
@@ -140,6 +141,12 @@ sub _print_result {
$self->_wrapped_plugin('print_result', @result);
}
+sub _loop {
+ my $self = shift;
+
+ $self->_chained_plugin('loop');
+}
+
sub _wrapped_plugin {
my $self = shift;
my @plugins = ref($_[0]) ? @{ shift() } : $self->plugins;
diff --git a/lib/Reply/Plugin/FancyPrompt.pm b/lib/Reply/Plugin/FancyPrompt.pm
index aec5b82..d998763 100644
--- a/lib/Reply/Plugin/FancyPrompt.pm
+++ b/lib/Reply/Plugin/FancyPrompt.pm
@@ -14,7 +14,12 @@ sub new {
sub prompt {
my $self = shift;
my ($next) = @_;
- return $self->{counter}++ . $next->();
+ return $self->{counter} . $next->();
+}
+
+sub loop {
+ my $self = shift;
+ $self->{counter}++;
}
1;