From e0845072109fce647b5b61076f8bba978d3adf65 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 7 Oct 2015 18:29:12 +0200 Subject: route_interesting support in aseag-m --- bin/aseag-m | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'bin/aseag-m') diff --git a/bin/aseag-m b/bin/aseag-m index 22303a6..7edb7d6 100755 --- a/bin/aseag-m +++ b/bin/aseag-m @@ -45,11 +45,12 @@ if ( @ARGV != 1 ) { for my $efield (@edata_pre) { given ($efield) { - when ('a') { $edata{route_after} = 1; $calculate_routes = 1 } - when ('b') { $edata{route_before} = 1; $calculate_routes = 1 } - when ('f') { $edata{route_full} = 1; $calculate_routes = 1 } - when ('T') { $edata{relative_times} = 1 } - default { $edata{$efield} = 1 } + when ('a') { $edata{route_after} = 1; $calculate_routes = 1 } + when ('b') { $edata{route_before} = 1; $calculate_routes = 1 } + when ('f') { $edata{route_full} = 1; $calculate_routes = 1 } + when ('r') { $edata{route_interesting} = 1; $calculate_routes = 1 } + when ('T') { $edata{relative_times} = 1 } + default { $edata{$efield} = 1 } } } @@ -76,7 +77,7 @@ sub show_version { sub display_result { my (@lines) = @_; - my @format = qw(%- %- %-); + my @format = qw(%- %- %- %-); if ( not @lines ) { die("Nothing to show\n"); @@ -86,17 +87,17 @@ sub display_result { $format[0] = q{%}; } - for my $i ( 0 .. 2 ) { + for my $i ( 0 .. 3 ) { $format[$i] .= max map { length( $_->[$i] ) } @lines; $format[$i] .= 's'; } for my $line (@lines) { - printf( join( q{ }, @format ) . "\n", @{$line}[ 0 .. 2 ] ); + printf( join( q{ }, @format ) . "\n", @{$line}[ 0 .. 3 ] ); - if ( @{ $line->[3] } ) { - for my $route ( @{ $line->[3] } ) { + if ( @{ $line->[4] } ) { + for my $route ( @{ $line->[4] } ) { printf( join( q{ }, @format ) . "\n", @{$route} ); } print "\n"; @@ -188,6 +189,7 @@ sub show_results { $d->datetime->subtract_datetime($dt_now) ), $d->line, + q{}, $d->destination, [ show_route( $dt_now, $dt_format, @route ) ], ); @@ -195,13 +197,17 @@ sub show_results { else { @line = ( $d->datetime->strftime($strftime_format), - $d->line, $d->destination, + $d->line, q{}, $d->destination, [ show_route( $dt_now, $dt_format, @route ) ], ); } if ( $edata{route_before} ) { - @{ $line[3] } = reverse @{ $line[3] }; + @{ $line[4] } = reverse @{ $line[4] }; + } + + if ( $edata{route_interesting} ) { + $line[2] = join( q{ }, $d->route_interesting ); } push( @output, \@line ); -- cgit v1.2.3