[Bps-public-commit] r16860 - sd/trunk/lib/App/SD/CLI

jesse at bestpractical.com jesse at bestpractical.com
Sat Nov 15 23:17:29 EST 2008


Author: jesse
Date: Sat Nov 15 23:17:29 2008
New Revision: 16860

Modified:
   sd/trunk/lib/App/SD/CLI/Dispatcher.pm

Log:
* Added dispatcher rules for bitching about missing commands

Modified: sd/trunk/lib/App/SD/CLI/Dispatcher.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Dispatcher.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Dispatcher.pm	Sat Nov 15 23:17:29 2008
@@ -70,6 +70,8 @@
         on create => run_command('Ticket::Attachment::Create');
         on search => run_command('Ticket::Attachment::Search');
     };
+
+
 };
 
 under attachment => sub {
@@ -81,12 +83,21 @@
 # 'sd ticket display --id 14' -> 'sd display --type ticket --id 14'
 on qr{^(ticket|comment|attachment) \s+ (.*)}xi => sub {
     my $self = shift;
-    $self->context->set_arg(type => $1);
-    run($2, $self, @_);
+    my $type = $1;
+    my $redispatch_to = $2;
+    $self->context->set_arg(type => $type);
+    run($redispatch_to, $self, @_);
 };
 
 redispatch_to('Prophet::CLI::Dispatcher');
 
+on qr/^(.*)$/ => sub {
+   my $self = shift;
+   my $command = $1;
+   die "The command you ran, '$command', could not be found. Perhaps running '$0 help' would help?\n";
+
+};
+
 sub run_command {Prophet::CLI::Dispatcher::run_command(@_) }
 
 



More information about the Bps-public-commit mailing list