summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rwxr-xr-xutils/rhrd-schedules3
-rwxr-xr-xutils/rhrd-show31
2 files changed, 33 insertions, 1 deletions
diff --git a/utils/rhrd-schedules b/utils/rhrd-schedules
index 123302c..4f07db5 100755
--- a/utils/rhrd-schedules
+++ b/utils/rhrd-schedules
@@ -21,6 +21,9 @@
#
use strict;
+
+use lib '../lib';
+
use RHRD::rddb;
use RHRD::utils;
use DateTime;
diff --git a/utils/rhrd-show b/utils/rhrd-show
index 880ac5e..58ed014 100755
--- a/utils/rhrd-show
+++ b/utils/rhrd-show
@@ -28,6 +28,7 @@ use Date::Calc;
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";
@@ -49,6 +50,27 @@ sub list
return 0;
}
+sub search
+{
+ my ($ctx, $searchexp) = @_;
+
+ my @shows = RHRD::rddb::list_shows($ctx);
+ if(!defined $shows[0] && defined $shows[1]) {
+ print STDERR "$shows[1]: $shows[2]";
+ return 1;
+ }
+ my @sorted = sort { lc($a->{'TITLE'}) cmp lc($b->{'TITLE'}) } @shows;
+ for my $show (@sorted) {
+ next unless $show->{'TITLE'} =~ /$searchexp/i;
+
+ $show->{'DOW'} = 7 if $show->{'DOW'} == 0;
+ print $show->{'ID'} . ": " . $show->{'TITLE'} . ", ";
+ print join(", ", $show->{'RHYTHM'}, Date::Calc::Day_of_Week_to_Text($show->{'DOW'}), $show->{'STARTTIME'}, ($show->{'LEN'} . " min"));
+ print ", group: " . $show->{'GROUP'} . "\n";
+ }
+ return 0;
+}
+
sub show
{
my ($ctx, $showid) = @_;
@@ -70,7 +92,6 @@ sub show
}
-
sub add__check_arguments
{
my ($groupname, $name, $title, $num_carts, $rhythm, $dow, $starttime, $len) = @_;
@@ -294,6 +315,14 @@ if(defined $ctx) {
$ret = list($ctx, $ARGV[1])
}
}
+ elsif($cmd eq "search") {
+ if($num_args != 2) {
+ print_usage();
+ $ret = 1;
+ } else {
+ $ret = search($ctx, $ARGV[1])
+ }
+ }
elsif($cmd eq "show") {
if($num_args != 2) {
print_usage();