[Bps-public-commit] r16433 - in sd/branches/sd-dispatcher: .

sartak at bestpractical.com sartak at bestpractical.com
Tue Oct 21 13:15:54 EDT 2008


Author: sartak
Date: Tue Oct 21 13:15:52 2008
New Revision: 16433

Modified:
   sd/branches/sd-dispatcher/   (props changed)
   sd/branches/sd-dispatcher/lib/App/SD/CLI/Dispatcher.pm

Log:
 r74283 at onn:  sartak | 2008-10-21 13:13:26 -0400
 Modernize the existing code, most of which needs to be shot :)


Modified: sd/branches/sd-dispatcher/lib/App/SD/CLI/Dispatcher.pm
==============================================================================
--- sd/branches/sd-dispatcher/lib/App/SD/CLI/Dispatcher.pm	(original)
+++ sd/branches/sd-dispatcher/lib/App/SD/CLI/Dispatcher.pm	Tue Oct 21 13:15:52 2008
@@ -16,19 +16,19 @@
 on qr'^help (?:list|find)$' => sub { run('help search', @_); last_rule;};
 
 on qr{ticket \s+ give \s+ (.*) \s+ (.*)}xi => sub {
-    my %args = @_;
-    $args{context}->set_arg(type => 'ticket');
-    $args{context}->set_arg(id => $1);
-    $args{context}->set_arg(owner => $2);
-    run('update', %args);
+    my $self = shift;
+    $self->context->set_arg(type => 'ticket');
+    $self->context->set_arg(id => $1);
+    $self->context->set_arg(owner => $2);
+    run('update', $self, @_);
 };
 
 # allow type to be specified via primary commands, e.g.
 # 'sd ticket display --id 14' -> 'sd display --type ticket --id 14'
 on qr{^(ticket|comment|attachment) \s+ (.*)}xi => sub {
-    my %args = @_;
-    $args{context}->set_arg(type => $1);
-    run($2, %args);
+    my $self = shift;
+    $self->context->set_arg(type => $1);
+    run($2, $self, @_);
 };
 
 #on qr'^about$' => sub { run('help about'); last_rule;};
@@ -36,14 +36,14 @@
 
 # Run class based commands
 on qr{.} => sub {
-    my %args = @_;
-    my $cli = $args{cli};
+    my $self = shift;
+    my $cli = $self->cli;
 
     my @possible_classes;
 
     # we want to dispatch on the original command "ticket attachment create"
     # AND on the command we received "create"
-    for ([@{ $args{dispatching_on} }], [split ' ', $_]) {
+    for ([@{ $self->dispatching_on }], [split ' ', $_]) {
         my @pieces = __PACKAGE__->resolve_builtin_aliases(@$_);
 
         while (@pieces) {
@@ -53,8 +53,8 @@
     }
 
     for my $class (@possible_classes) {
-        if ($args{cli}->_try_to_load_cmd_class($class)) {
-            return $args{got_command}->($class) 
+        if ($cli->_try_to_load_cmd_class($class)) {
+            return $class->run;
         }
     }
 



More information about the Bps-public-commit mailing list