[Bps-public-commit] r16198 - sd/trunk/lib/App/SD/CLI/Command/Ticket

ruz at bestpractical.com ruz at bestpractical.com
Thu Oct 2 11:59:26 EDT 2008


Author: ruz
Date: Thu Oct  2 11:59:26 2008
New Revision: 16198

Modified:
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Create.pm
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Update.pm

Log:
* add TRY_AGAIN functionality in ticket update
* prompt_Yn is now part of Prophet::CLI::Command

Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Create.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Create.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Create.pm	Thu Oct  2 11:59:26 2008
@@ -53,16 +53,6 @@
     }
 };
 
-sub prompt_Yn {
-    my $self = shift;
-    my $msg = shift;
-    print "$msg [Y/n]: ";
-    my $a = <>;
-    chomp $a;
-    return 1 if $a =~ /^(|y|yes)$/i;
-    return 0;
-}
-
 __PACKAGE__->meta->make_immutable;
 no Moose;
 

Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Update.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Update.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Update.pm	Thu Oct  2 11:59:26 2008
@@ -18,6 +18,7 @@
         my $ticket_string_to_edit = $self->create_record_string($record);
         my $do_not_edit = $record->props_not_to_edit;
 
+        TRY_AGAIN:
         my $updated = $self->edit_text($ticket_string_to_edit);
 
         die "Aborted.\n"
@@ -43,7 +44,19 @@
         }
 
         # set the new props
-        $record->set_props( props => $props_ref );
+        my $error;
+        {
+            local $@;
+            eval { $record->set_props( props => $props_ref ) }
+                or $error = $@ || "Something went wrong!";
+        }
+        if ( $error ) {
+            print STDERR "Couldn't update the record, error:\n\n", $error, "\n";
+            die "Aborted.\n" unless $self->prompt_Yn( "Want to return back to editing?" );
+
+            ($ticket_string_to_edit, $error) = ($updated, '');
+            goto TRY_AGAIN;
+        }
 
         print 'Updated ticket ' . $record->luid . ' (' . $record->uuid . ")\n";
 



More information about the Bps-public-commit mailing list