diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-07-13 14:36:50 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-07-13 14:36:50 +0200 |
commit | f5b52ba5f5c6391a498a242b782f24252aef6bb7 (patch) | |
tree | ed3f1fa81860721ec212b878f53df35782e51061 /bin | |
parent | 784c3d193f669ede6bde3b9c734455a5eaf39546 (diff) |
Support multiple platforms
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/db-fakedisplay | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/bin/db-fakedisplay b/bin/db-fakedisplay index 7d7aec5..f9a4831 100755 --- a/bin/db-fakedisplay +++ b/bin/db-fakedisplay @@ -14,16 +14,16 @@ our $VERSION = '0.00'; sub show_help { my ($exit_status) = @_; - say 'Usage: db-fakedisplay <station> <platform>'; + say 'Usage: db-fakedisplay <station> <platforms ...>'; exit $exit_status; } -if (@ARGV != 2) { +if (@ARGV < 2) { show_help(1); } -my ($station, $platform) = @ARGV; +my ($station, @platforms) = @ARGV; my $template_file = dist_file('db-fakedisplay', 'template.html'); my $template = HTML::Template->new( filename => $template_file); @@ -31,20 +31,30 @@ my $status = Travel::Status::DE::DeutscheBahn->new( station => $station ); -my $info = first { $_->platform eq $platform } $status->results; - -if (not defined $info) { - say STDERR 'Got no departures for that platform'; - exit 1; +my @params; + +for my $platform (@platforms) { + my $info = first { $_->platform eq $platform } $status->results; + + if (not defined $info) { + push(@params, { + platform => $platform + }); + next; + } + + push(@params, { + time => $info->time, + train => $info->train, + via => [ map { { stop => $_ } } $info->route_interesting(3) ], + destination => $info->destination, + platform => $info->platform, + info => $info->info, + }); } $template->param( - time => $info->time, - train => $info->train, - via => [ map { { stop => $_ } } $info->route_interesting(3) ], - destination => $info->destination, - platform => $info->platform, - info => $info->info, + platform => \@params, ); say $template->output; |