From d280566f9278c24228cf57090c14ee4d705348a1 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 4 Jul 2014 18:27:06 -0400 Subject: simplify --- lib/Reply.pm | 17 ++++++++++++----- lib/Reply/App.pm | 11 ++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/Reply.pm b/lib/Reply.pm index e4c663e..ad72fff 100644 --- a/lib/Reply.pm +++ b/lib/Reply.pm @@ -116,20 +116,27 @@ sub run { print "\n"; } -=method step($line) +=method step($line, $verbose) Runs a single iteration of the repl. If C<$line> is given, it will be used as the string to evaluate (and the C and C callbacks will not -be called). Returns true if the repl can continue, and false if it was -requested to quit. +be called). If C<$verbose> is true, the prompt and line will be displayed as +though they were typed. Returns true if the repl can continue, and false if it +was requested to quit. =cut sub step { my $self = shift; - my ($line) = @_; + my ($line, $verbose) = @_; - $line = $self->_read unless defined $line; + if (defined $line) { + print $self->_wrapped_plugin('prompt'), $line, "\n" + if $verbose; + } + else { + $line = $self->_read; + } return unless defined $line; diff --git a/lib/Reply/App.pm b/lib/Reply/App.pm index 7d93238..6fe66de 100644 --- a/lib/Reply/App.pm +++ b/lib/Reply/App.pm @@ -92,15 +92,8 @@ sub run { my $reply = Reply->new(%args); $reply->step("use $_") for @modules; - for my $line (@script_lines) { - print $reply->_wrapped_plugin('prompt'), $line, "\n"; - $reply->step($line); - } - for my $file (@argv) { - my $line = 'do "' . quotemeta($file) . '"'; - print $reply->_wrapped_plugin('prompt'), $line, "\n"; - $reply->step($line); - } + $reply->step($_, 1) for @script_lines; + $reply->step('do "' . quotemeta($_) . '"', 1) for @files; $reply->run; return 0; -- cgit v1.2.3