[Bps-public-commit] r14832 - in Prophet/branches/dispatcher: lib/Prophet/CLI

sartak at bestpractical.com sartak at bestpractical.com
Tue Aug 5 20:01:16 EDT 2008


Author: sartak
Date: Tue Aug  5 20:01:15 2008
New Revision: 14832

Modified:
   Prophet/branches/dispatcher/   (props changed)
   Prophet/branches/dispatcher/lib/Prophet/CLI/Dispatcher.pm

Log:
 r54143 at gorgoroth:  sartak | 2008-08-05 20:01:10 -0400
 Steal the old command logic, though it's not very declarative
 (but it passes all tests!)


Modified: Prophet/branches/dispatcher/lib/Prophet/CLI/Dispatcher.pm
==============================================================================
--- Prophet/branches/dispatcher/lib/Prophet/CLI/Dispatcher.pm	(original)
+++ Prophet/branches/dispatcher/lib/Prophet/CLI/Dispatcher.pm	Tue Aug  5 20:01:15 2008
@@ -14,8 +14,25 @@
     my $cli = shift;
     my %args = @_;
 
-    my $class = join '::', split ' ', $1;
-    $args{got_command}->($class);
+    my @possible_classes;
+
+    my @pieces = split ' ', $1;
+
+    for my $main ($cli->app_class, "Prophet") {
+        push @possible_classes, $main
+                              . "::CLI::Command::"
+                              . ucfirst lc $pieces[-1];
+    }
+
+    for my $main ($cli->app_class, "Prophet") {
+        push @possible_classes, $main . "::CLI::Command::NotFound";
+    }
+
+    for my $class (@possible_classes) {
+        if ($cli->_try_to_load_cmd_class($class)) {
+            return $args{got_command}->($class);
+        }
+    }
 };
 
 1;



More information about the Bps-public-commit mailing list