From 9a09a819c4a05a1ebe7dcfa0cfa6d1f63df9b7be Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 4 Jul 2014 18:22:18 -0400 Subject: also allow executing files (#36) --- lib/Reply/App.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Reply/App.pm b/lib/Reply/App.pm index 5a1004d..7d93238 100644 --- a/lib/Reply/App.pm +++ b/lib/Reply/App.pm @@ -42,7 +42,7 @@ sub run { my $cfgfile = '.replyrc'; my $exitcode; - my (@modules, @script_lines); + my (@modules, @script_lines, @files); my $parsed = GetOptionsFromArray( \@argv, 'cfg:s' => \$cfgfile, @@ -55,6 +55,13 @@ sub run { 'help' => sub { $exitcode = 0; usage() }, ); + @files = @argv; + for my $file (@files) { + if (!stat $file) { + die "Can't read $file: $!"; + } + } + if (!$parsed) { usage(1); $exitcode = 1; @@ -89,6 +96,11 @@ sub run { 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->run; return 0; -- cgit v1.2.3