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

sartak at bestpractical.com sartak at bestpractical.com
Tue Oct 21 14:01:19 EDT 2008


Author: sartak
Date: Tue Oct 21 14:01:18 2008
New Revision: 16442

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

Log:
 r74288 at onn:  sartak | 2008-10-21 13:18:30 -0400
 Steal resolve_builtin_aliases for now from Prophet trunk's dispatcher


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 14:01:18 2008
@@ -66,6 +66,29 @@
     ),
 );
 
+my %CMD_MAP = (
+    ls      => 'search',
+    new     => 'create',
+    edit    => 'update',
+    rm      => 'delete',
+    del     => 'delete',
+    list    => 'search',
+    display => 'show',
+);
+
+sub resolve_builtin_aliases {
+    my $self = shift;
+    my @cmds = @_;
+
+    if (my $replacement = $CMD_MAP{ lc $cmds[-1] }) {
+        $cmds[-1] = $replacement;
+    }
+
+    @cmds = map { ucfirst lc } @cmds;
+
+    return wantarray ? @cmds : $cmds[-1];
+}
+
 __PACKAGE__->meta->make_immutable;
 no Moose;
 



More information about the Bps-public-commit mailing list