[Bps-public-commit] r14507 - in Prophet/trunk: . lib/Prophet/CLI

sartak at bestpractical.com sartak at bestpractical.com
Fri Jul 25 05:38:17 EDT 2008


Author: sartak
Date: Fri Jul 25 05:38:15 2008
New Revision: 14507

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

Log:
 r65183 at onn:  sartak | 2008-07-25 05:28:09 -0400
 Add some support for more complex prop relationships expressed through the CLI


Modified: Prophet/trunk/lib/Prophet/CLI.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI.pm	Fri Jul 25 05:38:15 2008
@@ -79,6 +79,17 @@
     },
 );
 
+has prop_set => (
+    metaclass  => 'Collection::Array',
+    is         => 'rw',
+    isa        => 'ArrayRef',
+    default    => sub { [] },
+    auto_deref => 1,
+    provides   => {
+        push => 'add_to_prop_set',
+    },
+);
+
 =head2 _record_cmd
 
 handles the subcommand for a particular type
@@ -193,14 +204,16 @@
         die "$name doesn't look like --argument"
             if $sep == 0 && $name !~ /^--/;
 
-        my $val;
-
         if ($name eq '--' || $name eq '--props') {
             ++$sep;
             next;
         }
 
-        ($name,$val)= split(/=/,$name,2) if ($name =~/=/);
+        my $cmp = '=';
+        my $val;
+
+        ($name, $cmp, $val) = ($1, $2, $3)
+            if $name =~ /^(.*?)(!=|<>|=~|!~|=)(.*)$/;
         $name =~ s/^--//;
 
         # no value specified, pull it from the next argument, unless the next
@@ -208,6 +221,14 @@
         $val = shift @ARGV
             if !defined($val) && @ARGV && $ARGV[0] !~ /^--/;
 
+        if ($sep == 1) {
+            $self->add_to_prop_set({
+                name  => $name,
+                cmp   => $cmp,
+                value => $val,
+            });
+        }
+
         my $setter = $sep_method[$sep] or next;
         $self->$setter($name => $val);
     }

Modified: Prophet/trunk/lib/Prophet/CLI/Command.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command.pm	Fri Jul 25 05:38:15 2008
@@ -8,7 +8,7 @@
     handles => [
         qw/args  set_arg  arg  has_arg  delete_arg  arg_names/,
         qw/props set_prop prop has_prop delete_prop prop_names/,
-        'app_handle', 'run_one_command',
+        'prop_set', 'app_handle', 'run_one_command',
     ],
 );
 



More information about the Bps-public-commit mailing list