diff options
Diffstat (limited to 'bin/dbwagenreihung')
-rw-r--r-- | bin/dbwagenreihung | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/bin/dbwagenreihung b/bin/dbwagenreihung new file mode 100644 index 0000000..0c5b2fe --- /dev/null +++ b/bin/dbwagenreihung @@ -0,0 +1,36 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.020; +use utf8; + +our $VERSION = '0.00'; + +use Travel::Status::DE::IRIS; +use Travel::Status::DE::DBWagenreihung; + +my ($station, $train_number) = @ARGV; + +my $res = Travel::Status::DE::IRIS->new(station => $station, with_related => 1); + +if ($res->errstr) { + say STDERR $res->errstr; + exit 1; +} + +my @trains = grep { $_->train_no eq $train_number } $res->results; + +if (@trains != 1) { + say STDERR "Unable to find train in reported departures"; + exit 1; +} + +my $wr = Travel::Status::DE::DBWagenreihung->new( + departure => $trains[0]->sched_departure, + developer_mode => 1, + train_number => $train_number, +); + +for my $wagon ($wr->wagons) { + printf("%s %s\n", $wagon->number, $wagon->section); +} |