Index: trunk/Nebulous/bin/neb-cull
===================================================================
--- trunk/Nebulous/bin/neb-cull	(revision 24864)
+++ trunk/Nebulous/bin/neb-cull	(revision 24996)
@@ -16,5 +16,5 @@
 use Pod::Usage qw( pod2usage );
 
-my ($server, $volume);
+my ($server, $volume, $one_only);
 
 $server = $ENV{'NEB_SERVER'} unless $server;
@@ -23,4 +23,5 @@
     'server|s=s'    => \$server,
     'volume|v=s'    => \$volume,
+    'one_only|o'    => \$one_only,
 ) || pod2usage( 2 );
 
@@ -40,10 +41,24 @@
     unless defined $neb;
 
+my @cull_args;    
+push @cull_args, $key;
 if (defined $volume) {
-    $neb->cull($key, $volume)
-        or die "failed to replicate Nebulous key: $key";
+    push @cull_args, $volume;
+}
+
+if ($one_only) {
+    my $status = $neb->there_can_be_only_one(@cull_args);
+    if ($status == 0) {
+        die "not enough instances of Nebulous key: $key";
+    }
+    if (not defined $status or $status < 1) {
+        die "failed to cull Nebulous key: $key - " . $neb->err
+            if defined $neb->err;
+        die "failed to cull Nebulous key: $key";
+    }
 } else {
-    $neb->cull($key)
-        or die "failed to replicate Nebulous key: $key";
+    unless (defined $neb->cull(@cull_args)) {
+        die "failed to cull Nebulous key: $key - " . $neb->err;
+    }
 }
 
@@ -58,5 +73,5 @@
 =head1 SYNOPSIS
 
-    neb-cull [--server <URL>] [--volume <volume name>] <key>
+    neb-cull [--server <URL>] [--volume <volume name>] [--one_only] <key>
 
 =head1 DESCRIPTION
@@ -77,4 +92,12 @@
 
 Symbolic name of the volume to create the new instance on.
+
+Optional.
+
+=item * --one_only|-o
+
+Removes all but one instances of an object.  Any inaccessible instances are
+removed.  If C<--volume> is specified, and an instance exists on that volume,
+all instances but the one on that volume are removed.
 
 Optional.
@@ -110,5 +133,5 @@
 =head1 COPYRIGHT
 
-Copyright (C) 2007-2008  Joshua Hoblitt.  All rights reserved.
+Copyright (C) 2007-2009  Joshua Hoblitt.  All rights reserved.
 
 This program is free software; you can redistribute it and/or modify it under
