[Bps-public-commit] r14757 - in sd: trunk/lib/App/SD/CLI/Command/Ticket

spang at bestpractical.com spang at bestpractical.com
Mon Aug 4 13:51:58 EDT 2008


Author: spang
Date: Mon Aug  4 13:51:56 2008
New Revision: 14757

Added:
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Search.pm
Modified:
   sd/   (props changed)

Log:
 r47661 at loki:  spang | 2008-08-04 18:49:17 +0100
 implement --sort option for search which sorts the output by creation date


Added: sd/trunk/lib/App/SD/CLI/Command/Ticket/Search.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Search.pm	Mon Aug  4 13:51:56 2008
@@ -0,0 +1,26 @@
+package App::SD::CLI::Command::Ticket::Search;
+use Moose;
+extends 'Prophet::CLI::Command::Search';
+
+# frob the sort routine before running prophet's search command
+before run => sub {
+    my $self = shift;
+
+    # sort output by created date if user specifies --sort
+    if ($self->has_arg('sort')) {
+        # some records might not have creation dates
+        no warnings 'uninitialized';
+        # sort by creation date
+        my $sort_routine = sub {
+            my @records = @_;
+            return (sort { $a->prop('created') cmp $b->prop('created') } @records);
+        };
+        $self->sort_routine($sort_routine);
+    }
+};
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+



More information about the Bps-public-commit mailing list