From 529ef1c349d22c89953134448ab8a6b2279aa991 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 13 Sep 2011 10:55:07 +0200 Subject: efa-m(1): Add --line/--platform options to filter output --- Changelog | 4 ++++ bin/efa-m | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Changelog b/Changelog index 23d2922..ab9c42a 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,7 @@ +git HEAD + + * Add --platform / --line options to filter output + Travel::Status::DE::VRR 0.01 - Sun Sep 11 2011 * Initial release diff --git a/bin/efa-m b/bin/efa-m index 1b7fc37..de09aa2 100755 --- a/bin/efa-m +++ b/bin/efa-m @@ -10,15 +10,18 @@ use List::Util qw(max); use Travel::Status::DE::VRR; my ( $date, $time, $input_type ); +my ( @grep_lines, @grep_platforms ); my @output; binmode( STDOUT, ':encoding(utf-8)' ); GetOptions( - 'd|date=s' => \$date, - 'h|help' => sub { show_help(0) }, - 't|time=s' => \$time, - 'V|version' => \&show_version, + 'd|date=s' => \$date, + 'h|help' => sub { show_help(0) }, + 'l|line=s@' => \@grep_lines, + 'p|platform=s@' => \@grep_platforms, + 't|time=s' => \$time, + 'V|version' => \&show_version, ) or show_help(1); @@ -26,6 +29,10 @@ if ( @ARGV != 2 ) { show_help(1); } +# --line=foo,bar support +@grep_lines = split( qr{,}, join( q{,}, @grep_lines ) ); +@grep_platforms = split( qr{,}, join( q{,}, @grep_platforms ) ); + my ( $place, $input ) = @ARGV; if ( $input =~ s{ ^ (? address|poi|stop) : }{}x ) { @@ -95,6 +102,15 @@ if ( my $err = $status->errstr ) { for my $d ( $status->results ) { + if ( + ( @grep_lines and not( $d->line ~~ \@grep_lines ) ) + or ( @grep_platforms + and not( substr( $d->platform, 6 ) ~~ \@grep_platforms ) ) + ) + { + next; + } + push( @output, [ $d->time, $d->platform, $d->line, $d->destination, $d->info ] ); } @@ -131,6 +147,16 @@ I. Supported types are B
and B (point of interest). Show departures for I instead of today +=item B<-l>, B<--line> I + +Only show departures of I (comma-separatad list, option may be +repeated) + +=item B<-p>, B<--platform> I + +Only show departures at I (comma-separated list, option may be +repeated). Note that the C<< Bstg. >> / C<< Gleis >> prefix must be omitted. + =item B<-t>, B<--time> I Show departures starting at I