diff options
Diffstat (limited to 'utils/rhrd-pool')
-rwxr-xr-x | utils/rhrd-pool | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/utils/rhrd-pool b/utils/rhrd-pool index 93e943c..23b1cb2 100755 --- a/utils/rhrd-pool +++ b/utils/rhrd-pool @@ -29,7 +29,8 @@ use Date::Calc; sub print_usage { print STDERR "Usage: rhrd-pool list\n" . - " rhrd-pool (show|remove) <short-name>\n" . + " rhrd-pool show <short-name>\n" . + " rhrd-pool remove <short-name> [--force]\n" . " rhrd-pool add <groupname> <title>\n" . " rhrd-pool edit <short-name> <title>\n"; } @@ -179,7 +180,23 @@ sub edit sub remove { - my ($ctx, $shortname) = @_; + my ($ctx, $shortname, $force) = @_; + + if(defined($force) && $force ne "--force") { + print_usage(); + return 1; + } + + my @slots = RHRD::rddb::get_musicpool_clock_usage($ctx, $shortname); + if(!defined $slots[0] && defined $slots[1]) { + print STDERR "$slots[1]: $slots[2]"; + return 1; + } + if(scalar(@slots) > 0) { + print STDERR "musicpool is still in use (" . scalar(@slots) . " grid entries)\n"; + return 1 unless(defined($force)); + print STDERR " *** forced removal ***\n" + } my @results = RHRD::rddb::remove_musicpool($ctx, $shortname); if(!defined $results[0] && defined $results[2]) { @@ -220,11 +237,11 @@ if(defined $ctx) { } } elsif($cmd eq "remove") { - if($num_args != 2) { + if($num_args < 2 || $num_args > 3) { print_usage(); $ret = 1; } else { - $ret = remove($ctx, $ARGV[1]); + $ret = remove($ctx, $ARGV[1], $ARGV[2]); } } elsif($cmd eq "add") { |