#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
our $VERSION = '0.00';
use Getopt::Long qw(:config no_ignore_case);
use List::Util qw(max);
use Travel::Status::DE::VRR;
my ( $date, $time );
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,
) or show_help(1);
if (@ARGV != 2) {
show_help(1);
}
my ($place, $station) = @ARGV;
my $status = Travel::Status::DE::VRR->new(
date => $date,
place => $place,
name => $station,
time => $time,
);
sub show_help {
my ($code) = @_;
print "Usage: efa-m [-d
] [-t ] \n"
. "See also: man efa-m\n";
exit $code;
}
sub show_version {
say "efa-m version ${VERSION}";
exit 0;
}
sub display_result {
my (@lines) = @_;
my @line_length;
if ( not @lines ) {
die("Nothing to show\n");
}
for my $i ( 0 .. 3 ) {
$line_length[$i] = max map { length( $_->[$i] ) } @lines;
}
for my $line (@lines) {
printf(
join( q{ }, ( map { "%-${_}s" } @line_length ) ) . "\n",
@{$line}[ 0 .. 3 ]
);
}
return;
}
for my $d ( $status->results ) {
push(
@output,
[
$d->time,
$d->platform,
$d->line,
$d->destination,
]
);
}
display_result(@output);
__END__
=head1 NAME
efa-m - Inofficcial interface to the efa.vrr.de departure monitor
=head1 SYNOPSIS
B [B<-d> I] [B<-t> I