summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-12-08 06:39:50 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-12-08 06:39:50 (GMT)
commitd17b1ae4efbbc0c14928980df77407831b80b41a (patch)
tree0bf0d8ccf896078fca754ac459ffe4163d75ca47
parentf0ea9667eaca528221a87dc455cdd1900f50c4c1 (diff)
add confirmation to show/multi-show removal as well
-rwxr-xr-xutils/rhrd-show72
1 files changed, 58 insertions, 14 deletions
diff --git a/utils/rhrd-show b/utils/rhrd-show
index 5871f39..5ed0f4b 100755
--- a/utils/rhrd-show
+++ b/utils/rhrd-show
@@ -29,14 +29,16 @@ sub print_usage
{
print STDERR "Usage: rhrd-show list [ <group> ]\n" .
" rhrd-show search <expression>\n" .
- " rhrd-show (show|remove) <show-id>\n" .
+ " rhrd-show show <show-id>\n" .
" rhrd-show add <groupname> <name> <title> <num-carts> <rhythm> <dow> <starttime> <len> <type>\n" .
+ " rhrd-show remove [ -f ] <show-id>\n" .
" rhrd-show edit <show-id> <title> <rhythm> <dow> <starttime> <len> <type>\n" .
"\n" .
" multi show handling:\n" .
" rhrd-show multi-list\n" .
- " rhrd-show (multi-show|multi-remove) <multi-show-id>\n" .
+ " rhrd-show multi-show <multi-show-id>\n" .
" rhrd-show multi-add <title> <type> <week>=<show-id> [ <week>=<show-id> [ .. ] ]\n" .
+ " rhrd-show multi-remove [ -f ] <multi-show-id>\n" .
" rhrd-show multi-edit <multi-show-id> <title> <type> <week>=<show-id> [ <week>=<show-id> [ .. ] ]\n";
}
@@ -295,13 +297,22 @@ sub edit
sub remove
{
- my ($ctx, $showid) = @_;
+ my ($ctx, $showid, $force) = @_;
- my ($group, $status, $errorstring) = RHRD::rddb::get_show_group($ctx, $showid);
- unless(defined $group) {
+ my ($show, $status, $errorstring) = RHRD::rddb::get_show_info($ctx, $showid);
+ unless(defined $show) {
print STDERR $status . ": " . $errorstring . "\n";
return 1;
}
+ my $title = $show->{'TITLE'};
+ $title .= " (Wiederholung)" if($show->{'TYPE'} eq 'r');
+ $title .= " (Sondersendung)" if($show->{'TYPE'} eq 's');
+
+ if(!$force) {
+ return 1 if(!RHRD::utils::cmdline_ask_yn("do you really want to delete show '$title'"));
+ print("\n");
+ }
+ print("removing show: $title\n");
my @results = RHRD::rddb::remove_show($ctx, $showid);
if(!defined $results[0] && defined $results[2]) {
@@ -312,13 +323,13 @@ sub remove
print int($href->{cnt}) . " " . $href->{name} . " deleted\n";
}
- my @carts = RHRD::rddb::get_show_group_carts_used($ctx, $group);
+ my @carts = RHRD::rddb::get_show_group_carts_used($ctx, $show->{'GROUP'});
if(!defined $carts[0] && defined $carts[1]) {
print STDERR $carts[1] . ": " . $carts[2] . "\n";
return 1;
}
if(scalar @carts == 0) {
- print ">> group '" . $group . "' is now empty .. you should probably remove it!\n\n";
+ print ">> group '" . $show->{'GROUP'} . "' is now empty .. you should probably remove it!\n\n";
}
my @args = ($showid);
@@ -501,7 +512,7 @@ sub multi_show
sub multi_remove
{
- my ($ctx, $showid) = @_;
+ my ($ctx, $showid, $force) = @_;
my ($showid_min, $showid_max, $errorstring) = RHRD::rddb::get_multi_showid_range($ctx);
unless(defined $showid_min) {
@@ -513,7 +524,22 @@ sub multi_remove
return 1;
}
- (my $result, my $status, $errorstring) = RHRD::rddb::remove_multi_show($ctx, $showid);
+ (my $show, my $status, $errorstring) = RHRD::rddb::get_multi_show_info($ctx, $showid);
+ unless(defined $show) {
+ print STDERR "$errorstring\n";
+ return 1;
+ }
+ my $title = $show->{'TITLE'};
+ $title .= " (Wiederholung)" if($show->{'TYPE'} eq 'r');
+ $title .= " (Sondersendung)" if($show->{'TYPE'} eq 's');
+
+ if(!$force) {
+ return 1 if(!RHRD::utils::cmdline_ask_yn("do you really want to delete multi-show '$title'"));
+ print("\n");
+ }
+ print("removing multi-show: $title\n");
+
+ (my $result, $status, $errorstring) = RHRD::rddb::remove_multi_show($ctx, $showid);
unless(defined $result) {
print STDERR $status . ": " . $errorstring . "\n";
return 1;
@@ -570,11 +596,20 @@ 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]);
+ 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 "add") {
@@ -609,7 +644,7 @@ if(defined $ctx) {
shift @ARGV;
my $title = shift @ARGV;
my $type = shift @ARGV;
- $ret = multi_add($ctx, $type, @ARGV)
+ $ret = multi_add($ctx, $title, $type, @ARGV)
}
}
elsif($cmd eq "multi-show") {
@@ -621,11 +656,20 @@ if(defined $ctx) {
}
}
elsif($cmd eq "multi-remove") {
- if($num_args != 2) {
+ if($num_args < 2 || $num_args > 3) {
print_usage();
$ret = 1;
} else {
- $ret = multi_remove($ctx, $ARGV[1]);
+ if($num_args == 3) {
+ if($ARGV[1] ne '-f') {
+ print_usage();
+ $ret = 1;
+ } else {
+ $ret = multi_remove($ctx, $ARGV[2], 1);
+ }
+ } else {
+ $ret = multi_remove($ctx, $ARGV[1], 0);
+ }
}
}
elsif($cmd eq "multi-edit") {