summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-06-03 08:51:33 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-06-03 08:51:33 +0200
commit98c8f19f1996ec3ef7b6bdf2f84a7f04e1982248 (patch)
tree3446e67acac5c5ab1b50318261a28b9a75738f10 /bin
parent46fbe0aef7b81bbc80a081101e97cadf5968963d (diff)
implement experimental full-route feature
Diffstat (limited to 'bin')
-rwxr-xr-xbin/efa-m41
1 files changed, 39 insertions, 2 deletions
diff --git a/bin/efa-m b/bin/efa-m
index bda2185..3956bdb 100755
--- a/bin/efa-m
+++ b/bin/efa-m
@@ -2,6 +2,7 @@
use strict;
use warnings;
use 5.010;
+use utf8;
no if $] >= 5.018, warnings => "experimental::smartmatch";
@@ -80,6 +81,31 @@ sub show_version {
exit 0;
}
+sub format_route {
+ my (@route) = @_;
+
+ my $output = q{};
+
+ for my $stop (@route) {
+ if ( not $stop ) {
+ say "BUG";
+ next;
+ }
+ if ( $stop->{arr_time} eq $stop->{dep_time} ) {
+ $output .= sprintf( " %5s %40s %s\n",
+ $stop->{dep_time}, $stop->{stop}, $stop->{platform}, );
+ }
+ else {
+ $output .= sprintf(
+ "%5s → %5s %40s %s\n",
+ $stop->{arr_time}, $stop->{dep_time},
+ $stop->{stop}, $stop->{platform},
+ );
+ }
+ }
+ return $output;
+}
+
sub display_result {
my (@lines) = @_;
@@ -108,6 +134,10 @@ sub display_result {
join( q{ }, ( map { "%-${_}s" } @line_length ) ) . "\n",
@{$line}[ 0 .. 3 ]
);
+
+ if ( $line->[5] and $full_routes ) {
+ say $line->[5];
+ }
}
return;
@@ -136,6 +166,7 @@ sub show_results {
for my $d ( $status->results ) {
+ my @output_line;
my $platform = $d->platform;
my $dtime = (
$relative_times ? sprintf( '%2d min', $d->countdown ) : $d->time );
@@ -166,8 +197,14 @@ sub show_results {
$dtime .= ' (+' . $d->delay . ')';
}
- push( @output,
- [ $dtime, $platform, $d->line, $d->destination, $d->info ] );
+ @output_line
+ = ( $dtime, $platform, $d->line, $d->destination, $d->info );
+
+ if ($full_routes) {
+ $output_line[5] = format_route( $d->route_post );
+ }
+
+ push( @output, \@output_line );
}
display_result(@output);