summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-09-09 20:46:22 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-09-09 20:46:22 (GMT)
commit20ff694433ef9f658cc58da64484f008f95545da (patch)
tree38a24fa67f5a21f8de75dce9982dbc4e0392d20a /utils
parent23710d5bdb141ad4385be12765678659b68607b0 (diff)
added multi-show support (not working yet)
Diffstat (limited to 'utils')
-rwxr-xr-xutils/rhrd-show65
1 files changed, 64 insertions, 1 deletions
diff --git a/utils/rhrd-show b/utils/rhrd-show
index c52d63d..0c87c1e 100755
--- a/utils/rhrd-show
+++ b/utils/rhrd-show
@@ -21,17 +21,25 @@
#
use strict;
+use lib "../lib/";
use RHRD::rddb;
use RHRD::utils;
use Date::Calc;
+use Data::Dumper::Simple;
+
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 add <groupname> <name> <title> <num-carts> <rhythm> <dow> <starttime> <len>\n" .
- " rhrd-show edit <show-id> <title> <rhythm> <dow> <starttime> <len>\n";
+ " rhrd-show edit <show-id> <title> <rhythm> <dow> <starttime> <len>\n" .
+ " multi show handling:\n" .
+ " rhrd-show multi-list\n" .
+ " rhrd-show (multi-show|multi-remove) <multi-show-id>\n" .
+ " rhrd-show (multi-add) <title> <show-id> [ <show-id> [ .. ] ]\n" .
+ " rhrd-show (multi-add-id|multi-remove-id) <multi-show-id> <show-id> [ <show-id> [ .. ] ]\n";
}
sub list
@@ -306,6 +314,43 @@ sub remove
return 0;
}
+sub multi_list
+{
+ my ($ctx) = @_;
+
+ my @mshows = RHRD::rddb::list_multi_shows($ctx);
+ if(!defined $mshows[0] && defined $mshows[1]) {
+ print STDERR "$mshows[1]: $mshows[2]";
+ return 1;
+ }
+ my @sorted = sort { lc($a->{'TITLE'}) cmp lc($b->{'TITLE'}) } @mshows;
+ for my $href (@sorted) {
+ print $href->{'ID'} . ": " . Dumper($href) . "\n";
+# print $href->{'ID'} . ": " . $href->{'TITLE'} . ": (" . join(@$href->{'SHOWS'}, ", ") . ")\n";
+ }
+ return 0;
+}
+
+
+sub multi_add
+{
+ my $ctx = shift;
+ my $title = shift;
+ my @shows = @_;
+
+ ## TODO check shows: needs to have format <week>:<showid>
+
+ my ($result, $status, $errorstring) = RHRD::rddb::create_multi_show($ctx, $title, @shows);
+ unless(defined $result) {
+ print STDERR $status . ": " . $errorstring . "\n";
+ return 1;
+ }
+
+ return 0;
+}
+
+
+
my $num_args = $#ARGV + 1;
if($num_args < 1) {
print_usage();
@@ -364,6 +409,24 @@ if(defined $ctx) {
$ret = edit($ctx, $ARGV[1], $ARGV[2], $ARGV[3], $ARGV[4], $ARGV[5], $ARGV[6]);
}
}
+ elsif($cmd eq "multi-list") {
+ if($num_args != 1) {
+ print_usage();
+ $ret = 1;
+ } else {
+ $ret = multi_list($ctx)
+ }
+ }
+ elsif($cmd eq "multi-add") {
+ if($num_args < 3) {
+ print_usage();
+ $ret = 1;
+ } else {
+ shift @ARGV;
+ my $title = shift @ARGV;
+ $ret = multi_add($ctx, $title, @ARGV)
+ }
+ }
else {
print_usage();
$ret = 1;