summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-07-04 18:27:06 -0400
committerJesse Luehrs <doy@tozt.net>2014-07-04 18:27:06 -0400
commitd280566f9278c24228cf57090c14ee4d705348a1 (patch)
tree2594866c2eae7e8a96d573bdeb0e07b8c573ee2a
parent9a09a819c4a05a1ebe7dcfa0cfa6d1f63df9b7be (diff)
downloadreply-d280566f9278c24228cf57090c14ee4d705348a1.tar.gz
reply-d280566f9278c24228cf57090c14ee4d705348a1.zip
simplify
-rw-r--r--lib/Reply.pm17
-rw-r--r--lib/Reply/App.pm11
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<prompt> and C<read_line> 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;