From a3dcdb0d05d46a48e9305a34c4d4e0b954d50d9b Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 30 May 2013 07:02:48 -0500 Subject: add a hook for the end of a cycle --- lib/Reply.pm | 9 ++++++++- lib/Reply/Plugin/FancyPrompt.pm | 7 ++++++- 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; -- cgit v1.2.3-54-g00ecf