[Bps-public-commit] r16114 - in Prophet/branches/dispatcher: . lib/Prophet/CLI

sartak at bestpractical.com sartak at bestpractical.com
Sat Sep 27 15:17:42 EDT 2008


Author: sartak
Date: Sat Sep 27 15:17:41 2008
New Revision: 16114

Removed:
   Prophet/branches/dispatcher/lib/Prophet/CLI/Command/Log.pm
Modified:
   Prophet/branches/dispatcher/   (props changed)
   Prophet/branches/dispatcher/lib/Prophet/CLI/Dispatcher.pm

Log:
 r72947 at onn:  sartak | 2008-09-27 15:17:31 -0400
 log command


Modified: Prophet/branches/dispatcher/lib/Prophet/CLI/Dispatcher.pm
==============================================================================
--- Prophet/branches/dispatcher/lib/Prophet/CLI/Dispatcher.pm	(original)
+++ Prophet/branches/dispatcher/lib/Prophet/CLI/Dispatcher.pm	Sat Sep 27 15:17:41 2008
@@ -146,6 +146,24 @@
     print $record->history_as_string;
 };
 
+on log => sub {
+    my $self   = shift;
+    my $handle = $self->cli->handle;
+    my $newest = $self->context->arg('last') || $handle->latest_sequence_no;
+    my $start  = $newest - ( $self->context->arg('count') || '20' );
+    $start = 0 if $start < 0;
+
+    $handle->traverse_changesets(
+        after    => $start,
+        callback => sub {
+            my $changeset = shift;
+            $self->changeset_log($changeset);
+        },
+    );
+
+};
+
+
 # catch-all. () makes sure we don't hit the annoying historical feature of
 # the empty regex meaning the last-used regex
 on qr/()/ => sub {
@@ -180,6 +198,30 @@
          . " or set the PROPHET_APP_CONFIG environment variable.\n\n";
 }
 
+sub changeset_log {
+    my $self      = shift;
+    my $changeset = shift;
+    print $changeset->as_string(
+        change_header => sub {
+            my $change = shift;
+            $self->change_header($change);
+        }
+    );
+}
+
+sub change_header {
+    my $self   = shift;
+    my $change = shift;
+    return
+          " # "
+        . $change->record_type . " "
+        . $self->cli->handle->find_or_create_luid(
+        uuid => $change->record_uuid )
+        . " ("
+        . $change->record_uuid . ")\n";
+}
+
+
 no Moose;
 __PACKAGE__->meta->make_immutable;
 



More information about the Bps-public-commit mailing list