summaryrefslogtreecommitdiff
path: root/utils/rhrd-show
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-05-20 13:54:40 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-05-20 13:54:40 (GMT)
commitfc63aa732e54d8ed072a9f939de43efdcd855fc6 (patch)
tree6ccd5ca1f7ad30d5d5ad95e77dd38d8225fd2db6 /utils/rhrd-show
parentb4fe0e03eb1a712e379c2100ef92553afd4b26ed (diff)
added rhrd-show search
Diffstat (limited to 'utils/rhrd-show')
-rwxr-xr-xutils/rhrd-show31
1 files changed, 30 insertions, 1 deletions
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();