diff options
Diffstat (limited to 'utils/rhrd-pool')
-rwxr-xr-x | utils/rhrd-pool | 52 |
1 files changed, 43 insertions, 9 deletions
diff --git a/utils/rhrd-pool b/utils/rhrd-pool index 7035902..36c4ab3 100755 --- a/utils/rhrd-pool +++ b/utils/rhrd-pool @@ -29,7 +29,7 @@ sub print_usage { print STDERR "Usage: rhrd-pool list\n" . " rhrd-pool show <short-name>\n" . - " rhrd-pool remove|clear <short-name> [--force]\n" . + " rhrd-pool remove|clear [ -f ] <short-name>\n" . " rhrd-pool add <groupname> <title>\n" . " rhrd-pool edit <short-name> <title>\n"; } @@ -181,10 +181,17 @@ sub remove { my ($ctx, $shortname, $force) = @_; - if(defined $force && $force ne "--force") { - print_usage(); + my ($pool, $status, $errorstring) = RHRD::rddb::get_musicpool_info($ctx, $shortname); + unless(defined $pool) { + print STDERR $status . ": " . $errorstring . "\n"; return 1; } + my $title = $pool->{'TITLE'} . " (" . $pool->{'SHORTNAME'} . ")"; + + if(!$force) { + return 1 if(!RHRD::utils::cmdline_ask_yn("do you really want to delete pool '$title'")); + print("\n"); + } my @slots = RHRD::rddb::get_musicpool_clock_usage($ctx, $shortname); if(!defined $slots[0] && defined $slots[1]) { @@ -193,10 +200,11 @@ sub remove } if(scalar(@slots) > 0) { print STDERR "musicpool is still in use (" . scalar(@slots) . " grid entries)\n"; - return 1 unless(defined($force)); + return 1 unless($force); print STDERR " *** forced removal ***\n" } + print("removing pool: $title\n"); my @results = RHRD::rddb::remove_musicpool($ctx, $shortname); if(!defined $results[0] && defined $results[2]) { print STDERR $results[1] . ": " . $results[2] . "\n"; @@ -213,10 +221,17 @@ sub clear { my ($ctx, $shortname, $force) = @_; - if(defined $force && $force ne "--force") { - print_usage(); + my ($pool, $status, $errorstring) = RHRD::rddb::get_musicpool_info($ctx, $shortname); + unless(defined $pool) { + print STDERR $status . ": " . $errorstring . "\n"; return 1; } + my $title = $pool->{'TITLE'} . " (" . $pool->{'SHORTNAME'} . ")"; + + if(!$force) { + return 1 if(!RHRD::utils::cmdline_ask_yn("do you really want to clear pool '$title'")); + print("\n"); + } my @slots = RHRD::rddb::get_musicpool_clock_usage($ctx, $shortname); if(!defined $slots[0] && defined $slots[1]) { @@ -225,10 +240,11 @@ sub clear } if(scalar(@slots) > 0) { print STDERR "musicpool is still in use (" . scalar(@slots) . " grid entries)\n"; - return 1 unless(defined($force)); + return 1 unless($force); print STDERR " *** forced clearing ***\n" } + print("clearing pool: $title\n"); my @results = RHRD::rddb::clear_musicpool($ctx, $shortname); if(!defined $results[0] && defined $results[2]) { print STDERR $results[1] . ": " . $results[2] . "\n"; @@ -272,7 +288,16 @@ if(defined $ctx) { print_usage(); $ret = 1; } else { - $ret = remove($ctx, $ARGV[1], $ARGV[2]); + if($num_args == 3) { + if($ARGV[1] ne '-f') { + print_usage(); + $ret = 1; + } else { + $ret = remove($ctx, $ARGV[2], 1); + } + } else { + $ret = remove($ctx, $ARGV[1], 0); + } } } elsif($cmd eq "clear") { @@ -280,7 +305,16 @@ if(defined $ctx) { print_usage(); $ret = 1; } else { - $ret = clear($ctx, $ARGV[1], $ARGV[2]); + if($num_args == 3) { + if($ARGV[1] ne '-f') { + print_usage(); + $ret = 1; + } else { + $ret = clear($ctx, $ARGV[2], 1); + } + } else { + $ret = clear($ctx, $ARGV[1], 0); + } } } elsif($cmd eq "add") { |