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

sartak at bestpractical.com sartak at bestpractical.com
Fri Jul 11 10:12:57 EDT 2008


Author: sartak
Date: Fri Jul 11 10:11:53 2008
New Revision: 13987

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

Log:
 r64111 at onn:  sartak | 2008-07-11 10:11:20 -0400
 Basic support for dividing args and props by -- or --props (but since tests still put props in args, and commands still look for props in args, it doesn't break tests yet :))


Modified: Prophet/trunk/lib/Prophet/CLI.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI.pm	Fri Jul 11 10:11:53 2008
@@ -64,6 +64,19 @@
     },
 );
 
+has props => (
+    metaclass  => 'Collection::Hash',
+    is         => 'rw',
+    isa        => 'HashRef',
+    default    => sub { {} },
+    provides   => {
+        set    => 'set_prop',
+        get    => 'prop',
+        exists => 'has_prop',
+        delete => 'delete_prop',
+    },
+);
+
 =head2 _record_cmd
 
 handles the subcommand for a particular type
@@ -154,12 +167,23 @@
     my @primary;
     push @primary, shift @ARGV while ( $ARGV[0] && $ARGV[0] =~ /^\w+$/ && $ARGV[0] !~ /^--/ );
 
+    my $sep = 0;
+    my @sep_method = (
+        'set_arg',
+        'set_prop',
+    );
+
     $self->primary_commands( \@primary );
 
     while (my $name = shift @ARGV) {
         die "$name doesn't look like --prop-name" if ( $name !~ /^--/ );
         my $val;
 
+        if ($name eq '--' || $name eq '--props') {
+            ++$sep;
+            next;
+        }
+
         ($name,$val)= split(/=/,$name,2) if ($name =~/=/);
         $name =~ s/^--//;
 
@@ -168,7 +192,8 @@
         $val = shift @ARGV
             if !defined($val) && @ARGV && $ARGV[0] !~ /^--/;
 
-        $self->set_arg($name => $val);
+        my $setter = $sep_method[$sep] or next;
+        $self->$setter($name => $val);
     }
 }
 



More information about the Bps-public-commit mailing list