Commit 529ef1c3 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

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

parent 7e287c9b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
git HEAD

    * Add --platform / --line options to filter output

Travel::Status::DE::VRR 0.01 - Sun Sep 11 2011

    * Initial release
+30 −4
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ 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)' );
@@ -17,6 +18,8 @@ binmode( STDOUT, ':encoding(utf-8)' );
GetOptions(
	'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,

@@ -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