[Bps-public-commit] r18845 - Shipwright/trunk/lib/Shipwright/Script

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Mar 19 01:38:56 EDT 2009


Author: sunnavy
Date: Thu Mar 19 01:38:55 2009
New Revision: 18845

Modified:
   Shipwright/trunk/lib/Shipwright/Script/Update.pm

Log:
add --delete-deps for update cmd. not use --remove-deps because the other cmds have the similar situation and they all use delete

Modified: Shipwright/trunk/lib/Shipwright/Script/Update.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Update.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script/Update.pm	Thu Mar 19 01:38:55 2009
@@ -6,7 +6,7 @@
 
 use base qw/App::CLI::Command Class::Accessor::Fast Shipwright::Script/;
 __PACKAGE__->mk_accessors(
-    qw/all follow builder utility inc version only_sources as add_deps/
+    qw/all follow builder utility inc version only_sources as add_deps delete_deps/
 );
 
 use Shipwright;
@@ -21,15 +21,16 @@
 
 sub options {
     (
-        'a|all'        => 'all',
-        'follow'       => 'follow',
-        'builder'      => 'builder',
-        'utility'      => 'utility',
-        'inc'          => 'inc',
-        'version=s'    => 'version',
-        'only-sources' => 'only_sources',
-        'as=s'         => 'as',
-        'add-deps=s'   => 'add_deps',
+        'a|all'         => 'all',
+        'follow'        => 'follow',
+        'builder'       => 'builder',
+        'utility'       => 'utility',
+        'inc'           => 'inc',
+        'version=s'     => 'version',
+        'only-sources'  => 'only_sources',
+        'as=s'          => 'as',
+        'add-deps=s'    => 'add_deps',
+        'delete-deps=s' => 'delete_deps',
     );
 }
 
@@ -76,6 +77,21 @@
             }
         }
     }
+    elsif ( $self->delete_deps ) {
+        my @deps = split /\s*,\s*/, $self->delete_deps;
+        my $name = shift or confess 'need name arg';
+        my $requires = $shipwright->backend->requires( name => $name ) || {};
+        for my $dep ( @deps ) {
+            for my $type ( qw/requires build_requires recommends/ ) {
+                delete $requires->{$type}{$dep} if $requires->{$type};
+            }
+
+            $shipwright->backend->_yml( "/scripts/$name/require.yml", $requires );
+            my $refs = $shipwright->backend->refs;
+            $refs->{$dep}-- if $refs->{$dep} > 0;
+            $shipwright->backend->refs($refs);
+        }
+    }
     else {
         $map    = $shipwright->backend->map    || {};
         $source = $shipwright->backend->source || {};



More information about the Bps-public-commit mailing list