summaryrefslogtreecommitdiff
path: root/bin/db-ris
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-06-24 10:10:35 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-06-24 10:10:35 +0200
commit86c3e3526179429c5fa12ecb9aa2eb7d2c0a7a9b (patch)
treec84ef324d7010766c061b359a6aab83539aa2353 /bin/db-ris
parentc1edc66f2c9951f9075f91c209ccf51b7ab319ee (diff)
Add support for means of transport filtering
Diffstat (limited to 'bin/db-ris')
-rwxr-xr-xbin/db-ris17
1 files changed, 16 insertions, 1 deletions
diff --git a/bin/db-ris b/bin/db-ris
index c2c76d1..80d3d0f 100755
--- a/bin/db-ris
+++ b/bin/db-ris
@@ -9,14 +9,29 @@ use Getopt::Long;
use Travel::Status::DE::DeutscheBahn;
my ( $date, $time );
+my $types = q{};
+my %train_type;
+
+binmode( STDOUT, ':encoding(utf-8)' );
GetOptions(
'd|date=s' => \$date,
+ 'm|mot=s' => \$types,
't|time=s' => \$time,
);
+for my $type ( split( qr{,}, $types ) ) {
+ if ( substr( $type, 0, 1 ) eq q{!} ) {
+ $train_type{ substr( $type, 1 ) } = 0;
+ }
+ else {
+ $train_type{$type} = 1;
+ }
+}
+
my $status = Travel::Status::DE::DeutscheBahn->new(
date => $date,
+ mot => \%train_type,
station => shift,
time => $time,
);
@@ -58,7 +73,7 @@ for my $d ( $status->departures() ) {
}
printf(
- "%5s %-10s %-80s %-20s %-2d %s\n",
+ "%5s %-10s %-80s %-20s %-2s %s\n",
$d->time, $d->train, join( q{ }, @via_show ),
$d->destination, $d->platform, $d->info
);