Skip to content
Browse files

efa-m(1): Add --line/--platform options to filter output

  • Loading branch information...
1 parent 7e287c9 commit 529ef1c349d22c89953134448ab8a6b2279aa991 @derf committed
Showing with 34 additions and 4 deletions.
  1. +4 −0 Changelog
  2. +30 −4 bin/efa-m
View
4 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
View
34 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

0 comments on commit 529ef1c

Please sign in to comment.
Something went wrong with that request. Please try again.