[Bps-public-commit] r16348 - in sd/trunk/lib/App/SD/CLI: . Command/Help

jesse at bestpractical.com jesse at bestpractical.com
Sat Oct 18 18:51:55 EDT 2008


Author: jesse
Date: Sat Oct 18 18:51:54 2008
New Revision: 16348

Modified:
   sd/trunk/lib/App/SD/CLI/Command.pm
   sd/trunk/lib/App/SD/CLI/Command/Help/Search.pm
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Search.pm

Log:
* added support for grouping search results 

Modified: sd/trunk/lib/App/SD/CLI/Command.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command.pm	Sat Oct 18 18:51:54 2008
@@ -65,19 +65,6 @@
     return $content;
 }
 
-=head2 sort_by_creation_date $records
-
-Given an arrayref to a list of records, returns a list of the records
-sorted by their C<created> property, in ascending order.
-
-=cut
-
-sub sort_by_creation_date {
-    my ($self, $records) = @_;
-
-    return (sort { $a->prop('created') cmp $b->prop('created') } @{$records});
-}
-
 no Moose::Role;
 
 1;

Modified: sd/trunk/lib/App/SD/CLI/Command/Help/Search.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Help/Search.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Help/Search.pm	Sat Oct 18 18:51:54 2008
@@ -9,15 +9,19 @@
 
 print <<EOF
  $cmd ticket search
-     Lists all tickets with a status that does not match 'closed'
+     List all tickets with a status that does not match 'closed'
  
  $cmd ticket search --regex abc
-     Lists all tickets with content matching 'abc'
+     List all tickets with content matching 'abc'
  
  $cmd ticket search -- status!=closed summary =~ http 
-     Lists all tickets with a status that does match closed
+     List all tickets with a status that does match closed
      and a summary matching 'http'
- 
+
+ $cmd ticket search --group owner
+      List all tickets with a status that does not match 'closed', 
+      grouped by owner
+
  $cmd ticket show 1234
      Show basic information for the ticket with local id 1234
  

Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm	Sat Oct 18 18:51:54 2008
@@ -13,7 +13,7 @@
     $record->load( uuid => $self->uuid );
 
     if (@{$record->comments}) {
-        for my $entry ($self->sort_by_creation_date($record->comments)) {
+        for my $entry ($self->sort_by_prop( 'created' => $record->comments)) {
             print "id: ".$entry->luid." (".$entry->uuid.")\n";
             print "created: ".$entry->prop('created')."\n\n";
             print $entry->prop('content')."\n\n";

Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Search.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Search.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Search.pm	Sat Oct 18 18:51:54 2008
@@ -13,8 +13,16 @@
         no warnings 'uninitialized';
         $self->sort_routine( sub {
                     my $records = shift;
-                    return $self->sort_by_creation_date($records) } );
+                    return $self->sort_by_prop( created => $records) } );
     }
+    if ($self->has_arg('group')) {
+        $self->group_routine( sub {
+                    my $records = shift;
+                    return $self->group_by_prop( $self->arg('group') => $records) } )
+    }
+
+
+
 };
 
 # implicit status != closed
@@ -22,8 +30,8 @@
     my $self = shift;
     my $ticket = shift;
 
-    return 0 if $ticket->prop('status') eq 'closed';
-    return 1;
+    return 1 if $ticket->prop('status') ne 'closed';
+    return 0;
 }
 
 __PACKAGE__->meta->make_immutable;



More information about the Bps-public-commit mailing list