[Bps-public-commit] r17388 - in Prophet/trunk/lib/Prophet: CLI CLI/Command

jesse at bestpractical.com jesse at bestpractical.com
Sat Dec 27 16:26:41 EST 2008


Author: jesse
Date: Sat Dec 27 16:26:41 2008
New Revision: 17388

Modified:
   Prophet/trunk/lib/Prophet/CLI/Command/Delete.pm
   Prophet/trunk/lib/Prophet/CLI/Command/History.pm
   Prophet/trunk/lib/Prophet/CLI/Command/Log.pm
   Prophet/trunk/lib/Prophet/CLI/Command/Show.pm
   Prophet/trunk/lib/Prophet/CLI/Command/Update.pm
   Prophet/trunk/lib/Prophet/CLI/RecordCommand.pm
   Prophet/trunk/lib/Prophet/CLIContext.pm

Log:
* refactor a bit to move uuid-requiring into clicontext

Modified: Prophet/trunk/lib/Prophet/CLI/Command/Delete.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Delete.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Delete.pm	Sat Dec 27 16:26:41 2008
@@ -6,7 +6,7 @@
 sub run {
     my $self = shift;
 
-    $self->require_uuid;
+    $self->context->require_uuid;
     my $record = $self->_load_record;
 
     if ( $record->delete ) {

Modified: Prophet/trunk/lib/Prophet/CLI/Command/History.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/History.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/History.pm	Sat Dec 27 16:26:41 2008
@@ -6,7 +6,7 @@
 sub run {
     my $self = shift;
 
-    $self->require_uuid;
+    $self->context->require_uuid;
     my $record = $self->_load_record;
 
     print $record->history_as_string;

Modified: Prophet/trunk/lib/Prophet/CLI/Command/Log.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Log.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Log.pm	Sat Dec 27 16:26:41 2008
@@ -8,7 +8,6 @@
     my $newest = $self->arg('last') || $handle->latest_sequence_no;
     my $start  = $newest - ( $self->arg('count') || '20' );
     $start = 0 if $start < 0;
-
     $handle->traverse_changesets(
         after    => $start,
         callback => sub {
@@ -38,10 +37,8 @@
     return
           " # "
         . $change->record_type . " "
-        . $self->app_handle->handle->find_or_create_luid(
-        uuid => $change->record_uuid )
-        . " ("
-        . $change->record_uuid . ")\n";
+            . $self->app_handle->handle->find_or_create_luid( uuid => $change->record_uuid )
+        . " (" . $change->record_uuid . ")\n";
 
 }
 

Modified: Prophet/trunk/lib/Prophet/CLI/Command/Show.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Show.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Show.pm	Sat Dec 27 16:26:41 2008
@@ -7,7 +7,7 @@
 sub run {
     my $self = shift;
 
-    $self->require_uuid;
+    $self->context->require_uuid;
     my $record = $self->_load_record;
 
     print $self->stringify_props(

Modified: Prophet/trunk/lib/Prophet/CLI/Command/Update.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Update.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Update.pm	Sat Dec 27 16:26:41 2008
@@ -26,7 +26,7 @@
 sub run {
     my $self = shift;
 
-    $self->require_uuid;
+    $self->context->require_uuid;
     my $record = $self->_load_record;
 
     my $new_props = $self->edit_record($record);

Modified: Prophet/trunk/lib/Prophet/CLI/RecordCommand.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/RecordCommand.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/RecordCommand.pm	Sat Dec 27 16:26:41 2008
@@ -54,7 +54,7 @@
         return $class->new($constructor_args);
     }
     else {
-        Carp::confess("I was asked to get a record object, but I have neither a type nor a record class");
+       $self->fatal_error("I couldn't find that record. (You didn't specify a record type.)");
     }
 }
 

Modified: Prophet/trunk/lib/Prophet/CLIContext.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLIContext.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLIContext.pm	Sat Dec 27 16:26:41 2008
@@ -145,6 +145,23 @@
 }
 
 
+=head2 require_uuid
+
+Checks to make sure the uuid attribute is set. Prints an error and dies
+if it is not set.
+
+=cut
+
+sub require_uuid {
+    my $self    = shift;
+
+    if (!$self->has_uuid) {
+        my $type = $self->type;
+        die "This command requires a luid or uuid (use --id to specify).\n";
+    }
+}
+
+
 
 
 =head2 parse_args @args



More information about the Bps-public-commit mailing list