summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-06-27 10:55:42 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-06-27 10:55:42 +0200
commit4604cbdbc219d7c42ea9b3f0e98208ae44527232 (patch)
tree4affc6d12d392aa5238f2ef8364ba96dfeb90f91
parentf7ff1d6cb69fa40c930467fe2b7cc94133ce9fe9 (diff)
aseag-m: clean up output code, improve route format
-rwxr-xr-xbin/aseag-m66
1 files changed, 33 insertions, 33 deletions
diff --git a/bin/aseag-m b/bin/aseag-m
index a602052..529d9d1 100755
--- a/bin/aseag-m
+++ b/bin/aseag-m
@@ -87,7 +87,10 @@ sub display_result {
printf( join( q{ }, @format ) . "\n", @{$line}[ 0 .. 2 ] );
if ($full_route) {
- print "\n" . $line->[3] . "\n\n\n";
+ for my $route ( @{ $line->[3] } ) {
+ printf( join( q{ }, @format ) . "\n", @{$route} );
+ }
+ print "\n";
}
}
@@ -134,49 +137,46 @@ sub show_results {
if ( ( @grep_lines and not( $d->line ~~ \@grep_lines ) ) ) {
next;
}
+ my @line;
if ($relative_times) {
- push(
- @output,
+ @line = (
+ $dt_format->format_duration(
+ $d->datetime->subtract_datetime($dt_now)
+ ),
+ $d->line,
+ $d->destination,
[
- $dt_format->format_duration(
- $d->datetime->subtract_datetime($dt_now)
- ),
- $d->line,
- $d->destination,
- join(
- "\n",
- map {
- sprintf(
- '%s %s',
- $dt_format->format_duration(
- $_->[0]->subtract_datetime($dt_now)
- ),
- $_->[1]
- )
- } $d->route_timetable
- )
+ map {
+ [
+ $dt_format->format_duration(
+ $_->[0]->subtract_datetime($dt_now)
+ ),
+ q{},
+ $_->[1]
+ ]
+ } $d->route_timetable
]
);
}
else {
- push(
- @output,
+ @line = (
+ $d->datetime->strftime($strftime_format),
+ $d->line,
+ $d->destination,
[
- $d->datetime->strftime($strftime_format),
- $d->line,
- $d->destination,
- join(
- "\n",
- map {
- sprintf( '%s %s',
- $_->[0]->strftime($strftime_format),
- $_->[1] )
- } $d->route_timetable
- )
+ map {
+ [ $_->[0]->strftime($strftime_format), q{}, $_->[1] ]
+ } $d->route_timetable
]
);
}
+
+ if ( $full_route and $full_route eq 'before' ) {
+ @{ $line[3] } = reverse @{ $line[3] };
+ }
+
+ push( @output, \@line );
}
display_result(@output);