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

spang at bestpractical.com spang at bestpractical.com
Thu Jul 31 08:36:43 EDT 2008


Author: spang
Date: Thu Jul 31 08:36:42 2008
New Revision: 14691

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

Log:
 r47478 at loki:  spang | 2008-07-31 13:36:28 +0100
 allow user to specify --edit to also use the ticket creation editor regardless of props given on the commandline (and delete that arg when done to avoid confusing prophet)


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	Thu Jul 31 08:36:42 2008
@@ -40,7 +40,8 @@
             $text .= $header;
         }
         if (my $props = $args{prefill_props}) {
-            my @ordering = (my $props_order = $args{props_order}) ?
+            my $props_order;
+            my @ordering = ($props_order = $args{props_order}) ?
                                 @$props_order : keys %$props;
             $text .= join "\n", map { "$_: $props->{$_}" } @ordering;
         }

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 Jul 31 08:36:42 2008
@@ -12,14 +12,21 @@
     my $record = $self->_get_record_class;
     my @prop_set = $self->prop_set;
 
-    # only invoke editor if no props specified on the commandline
-    if (!@prop_set) {
+    # only invoke editor if no props specified on the commandline or edit arg
+    # specified
+    if (!@prop_set || $self->has_arg('edit')) {
         my @props = grep {!/^id$/} $record->props_to_show;
+
         my %prefill_props;
         # these props must exist in the hash, even if they have no value
-        foreach my $prop (@props) { $prefill_props{$prop} = undef; }
+        map { $prefill_props{$_} = undef } @props;
         # set default props
         $record->default_props(\%prefill_props);
+        if ($self->has_arg('edit')) {
+            # override with props specified on the commandline
+            map { $prefill_props{$_} = $self->prop($_) if $self->has_prop($_) } @props;
+            $self->delete_arg('edit');
+        }
         # undef values are noisy later when we want to interpolate the hash
         map { $prefill_props{$_} = '' if !defined($prefill_props{$_}) } @props;
 



More information about the Bps-public-commit mailing list