summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-04-29 12:20:16 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-04-29 12:26:46 (GMT)
commitac81019e73049c079d3b9ea8c4187a04bc1833f4 (patch)
tree7fce5730e1660e77044fe0c2437062271cfc65aa /utils
parentfbe0303d3cc74f355beb49fcd6ac6d2cebe3851f (diff)
improved show info output
moved command line parsing of week and dow to lib
Diffstat (limited to 'utils')
-rwxr-xr-xutils/rhrd-schedules59
-rwxr-xr-xutils/rhrd-show15
2 files changed, 28 insertions, 46 deletions
diff --git a/utils/rhrd-schedules b/utils/rhrd-schedules
index fa52226..2d509a9 100755
--- a/utils/rhrd-schedules
+++ b/utils/rhrd-schedules
@@ -144,45 +144,31 @@ sub show__day
# (W1|W2|W3|W4|ALL)
sub parse_rdweek
{
- my ($dow) = @_;
-
- if(uc($dow) eq "W1") {
- return(1);
- } elsif(uc($dow) eq "W2") {
- return(2);
- } elsif(uc($dow) eq "W3") {
- return(3);
- } elsif(uc($dow) eq "W4") {
- return(4);
- } elsif(uc($dow) eq "ALL") {
- return(1, 2, 3, 4);
+ my ($week) = @_;
+ if(uc($week) eq "ALL") {
+ return (1, 2, 3, 4);
}
- return ();
+ my ($w, undef, $hint) = RHRD::utils::cmdline_rdweek($week);
+ unless(defined($w)) {
+ print "error parsing week: $week, " . $hint . " or ALL\n";
+ return ();
+ }
+ return $w;
}
# (MO|TU|WE|TH|FR|SA|SU|ALL)
sub parse_dow
{
my ($dow) = @_;
-
- if(uc($dow) eq "MO") {
- return(1);
- } elsif(uc($dow) eq "TU") {
- return(2);
- } elsif(uc($dow) eq "WE") {
- return(3);
- } elsif(uc($dow) eq "TH") {
- return(4);
- } elsif(uc($dow) eq "FR") {
- return(5);
- } elsif(uc($dow) eq "SA") {
- return(6);
- } elsif(uc($dow) eq "SU") {
- return(7);
- } elsif(uc($dow) eq "ALL") {
- return(1, 2, 3, 4, 5, 6, 7);
+ if(uc($dow) eq "ALL") {
+ return (1, 2, 3, 4, 5, 6, 7);
}
- return ();
+ my ($d, undef, $hint) = RHRD::utils::cmdline_dow($dow);
+ unless(defined($d)) {
+ print "error parsing day of week: $dow, " . $hint . " or ALL\n";
+ return ();
+ }
+ return $d;
}
sub cmp_dates
@@ -204,15 +190,10 @@ sub gen_dates
my ($week, $dow) = @_;
my @weeks = parse_rdweek($week);
- unless(@weeks) {
- print "error parsing week: $week, must be one of W1, W2, W3, W4, ALL\n";
- return ()
- }
+ return () unless(@weeks);
my @dows = parse_dow($dow);
- unless(@dows) {
- print "error parsing day of week: $dow, must be one of MO, TU, WE, TH, FR, SA, SU, ALL\n";
- return ()
- }
+ return () unless(@dows);
+
my $curweek = RHRD::utils::get_rd_week();
my @today = Date::Calc::Today();
diff --git a/utils/rhrd-show b/utils/rhrd-show
index a25ceff..3cac649 100755
--- a/utils/rhrd-show
+++ b/utils/rhrd-show
@@ -23,6 +23,7 @@
use strict;
use RHRD::rddb;
use RHRD::utils;
+use Date::Calc;
sub print_usage
{
@@ -55,15 +56,14 @@ sub show
print STDERR "$carts[1]: $carts[2]\n";
return 1;
}
- my ($title, undef, $status, $errorstring) = RHRD::rddb::get_show_title_and_log($ctx, $show_id);
- unless (defined $title) {
+ my ($show, $status, $errorstring) = RHRD::rddb::get_show_info($ctx, $show_id);
+ unless (defined $show) {
print STDERR "$errorstring\n";
return 1;
}
- print $title . ":\n";
- for my $cart (@carts) {
- print " > " . $cart . "\n";
- }
+ $show->{'DOW'} = 7 if $show->{'DOW'} == 0;
+ print $show->{'TITLE'} . ": " . join(", ", $show->{'RHYTHM'}, Date::Calc::Day_of_Week_to_Text($show->{'DOW'}), $show->{'STARTTIME'}, ($show->{'LEN'} . " min")) . "\n";
+ print " carts(" . scalar(@carts) . "): " . join(", ", @carts) . " \n";
return 0;
}
@@ -96,7 +96,7 @@ sub add__check_arguments
return 1;
}
- ($result, $err, $hint) = RHRD::utils::dropbox_param_dow_ok($dow);
+ ($result, $err, $hint) = RHRD::utils::cmdline_dow($dow);
unless($result) {
print STDERR $err . "\n " . $hint . "\n";
return 1;
@@ -125,6 +125,7 @@ sub add
if($ret) {
return $ret;
}
+ ($dow, undef, undef) = RHRD::utils::cmdline_dow($dow);
print " * creating show: " . $title . " (" . $name . ") for group '" . $groupname . "'\n";