[Bps-public-commit] r15102 - in Prophet/trunk: .

sartak at bestpractical.com sartak at bestpractical.com
Tue Aug 12 20:31:02 EDT 2008


Author: sartak
Date: Tue Aug 12 20:31:02 2008
New Revision: 15102

Modified:
   Prophet/trunk/   (props changed)
   Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm

Log:
 r69441 at onn:  sartak | 2008-08-12 20:30:56 -0400
 Refactor read/eval out into methods so subclasses can wrap them if desired


Modified: Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm	Tue Aug 12 20:31:02 2008
@@ -32,6 +32,24 @@
         'Type "help", "about", or "copying for more information.',
 }
 
+sub read {
+    my $self = shift;
+    $self->readline($self->prompt);
+}
+
+sub eval {
+    my $self = shift;
+    my $line = shift;
+
+    local @ARGV = split ' ', $line;
+
+    eval {
+        local $SIG{__DIE__} = 'DEFAULT';
+        $self->cli->run_one_command;
+    };
+    warn $@ if $@;
+}
+
 sub run {
     my $self = shift;
 
@@ -40,18 +58,13 @@
     print $self->preamble . "\n";
 
     $self->cli->interactive_shell(1);
-    while (defined(local $_ = $self->readline($self->prompt))) {
+    while (defined(local $_ = $self->read)) {
         next if /^\s*$/;
 
         last if /^\s*q(?:uit)?\s*$/i
              || /^\s*exit\s*$/i;
 
-        local @ARGV = split ' ', $_;
-        eval {
-            local $SIG{__DIE__} = 'DEFAULT';
-            $self->cli->run_one_command;
-        };
-        warn $@ if $@;
+        $self->eval($_);
     }
 }
 



More information about the Bps-public-commit mailing list