summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-09-13 10:55:07 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-09-13 10:55:07 +0200
commit529ef1c349d22c89953134448ab8a6b2279aa991 (patch)
treef2690639522403f9626a757ea195ceb17acffed6 /bin
parent7e287c9b63a356e09ee6921dca626f8a68df5634 (diff)
efa-m(1): Add --line/--platform options to filter output
Diffstat (limited to 'bin')
-rwxr-xr-xbin/efa-m34
1 files changed, 30 insertions, 4 deletions
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{ ^ (?<type> 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<type>. Supported types are B<address> and B<poi> (point of interest).
Show departures for I<date> instead of today
+=item B<-l>, B<--line> I<lines>
+
+Only show departures of I<lines> (comma-separatad list, option may be
+repeated)
+
+=item B<-p>, B<--platform> I<platforms>
+
+Only show departures at I<platforms> (comma-separated list, option may be
+repeated). Note that the C<< Bstg. >> / C<< Gleis >> prefix must be omitted.
+
=item B<-t>, B<--time> I<hh:mm>
Show departures starting at I<time> instead of now