summaryrefslogtreecommitdiff
path: root/bin/dbwagenreihung
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-11-25 15:03:01 +0100
committerDaniel Friesel <derf@finalrewind.org>2018-11-25 15:03:01 +0100
commitacaf6fec0ea994e2901ebffbdd4bd3f5b46c77d6 (patch)
tree48064d46b53f54129454d3b580429fd250428352 /bin/dbwagenreihung
Initial commit
Diffstat (limited to 'bin/dbwagenreihung')
-rw-r--r--bin/dbwagenreihung36
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);
+}