[Bps-public-commit] r12224 - in Prophet/trunk: .

sartak at bestpractical.com sartak at bestpractical.com
Sat May 10 23:03:45 EDT 2008


Author: sartak
Date: Sat May 10 23:03:45 2008
New Revision: 12224

Modified:
   Prophet/trunk/   (props changed)
   Prophet/trunk/lib/Prophet/CLI.pm

Log:
 r55539 at onn:  sartak | 2008-05-10 22:52:45 -0400
 Allow defaults for edit_args


Modified: Prophet/trunk/lib/Prophet/CLI.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI.pm	Sat May 10 23:03:45 2008
@@ -244,23 +244,37 @@
     return $filtered;
 }
 
-=head2 edit_args [arg] -> hashref
+=head2 edit_args [arg], defaults -> hashref
 
-Returns a hashref of the passed-in arguments. If the "arg" argument is
-specified, (default "edit"), then L</edit_hash> is invoked on the argument
-list.
+Returns a hashref of the command arguments mixed in with any default arguments.
+If the "arg" argument is specified, (default "edit", use C<undef> if you only want default arguments), then L</edit_hash> is
+invoked on the argument list.
 
 =cut
 
 sub edit_args {
     my $self = shift;
-    my $arg = shift || 'edit';
+    my $arg  = shift || 'edit';
 
+    my $edit_hash;
     if (exists $self->args->{$arg}) {
         delete $self->args->{$arg};
-        return $self->edit_hash($self->args);
+        $edit_hash = 1;
     }
-    return $self->args;
+
+    my %args;
+    if (@_ == 1) {
+        %args = (%{ $self->args }, %{ $_[0] });
+    }
+    else {
+        %args = (%{ $self->args }, @_);
+    }
+
+    if ($edit_hash) {
+        return $self->edit_hash(\%args);
+    }
+
+    return \%args;
 }
 
 package Prophet::CLI::Command::Create;



More information about the Bps-public-commit mailing list