diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-05-20 13:54:40 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-05-20 13:54:40 (GMT) |
commit | fc63aa732e54d8ed072a9f939de43efdcd855fc6 (patch) | |
tree | 6ccd5ca1f7ad30d5d5ad95e77dd38d8225fd2db6 /utils | |
parent | b4fe0e03eb1a712e379c2100ef92553afd4b26ed (diff) |
added rhrd-show search
Diffstat (limited to 'utils')
-rwxr-xr-x | utils/rhrd-schedules | 3 | ||||
-rwxr-xr-x | utils/rhrd-show | 31 |
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(); |