#!/usr/bin/env perl
use strict;
use warnings;
use 5.014;
our $VERSION = '2.02';
use Encode qw(decode);
use Getopt::Long qw(:config no_ignore_case);
use List::MoreUtils qw(uniq);
use List::Util qw(first max);
use Travel::Status::DE::HAFAS;
my ( $date, $time );
my $arrivals = 0;
my $ignore_late = 0;
my $types = q{};
my $language;
my $developer_mode;
my ( $list_services, $service, $hafas_url );
my ( @excluded_mots, @exclusive_mots );
my @output;
binmode( STDOUT, ':encoding(utf-8)' );
for my $arg (@ARGV) {
$arg = decode( 'UTF-8', $arg );
}
GetOptions(
'a|arrivals' => \$arrivals,
'd|date=s' => \$date,
'h|help' => sub { show_help(0) },
'l|lang=s' => \$language,
'L|ignore-late' => \$ignore_late,
'm|mot=s' => \$types,
's|service=s' => \$service,
't|time=s' => \$time,
'u|url=s' => \$hafas_url,
'V|version' => \&show_version,
'devmode' => \$developer_mode,
'list' => \$list_services,
) or show_help(1);
if ($list_services) {
printf( "%-40s %-14s %s\n\n", 'operator', 'abbr. (-s)', 'url (-u)' );
for my $service ( Travel::Status::DE::HAFAS::get_services() ) {
printf( "%-40s %-14s %s\n", @{$service}{qw(name shortname url)} );
}
exit 0;
}
parse_mot_options();
my $status = Travel::Status::DE::HAFAS->new(
date => $date,
language => $language,
excluded_mots => \@excluded_mots,
exclusive_mots => \@exclusive_mots,
station => shift || show_help(1),
time => $time,
mode => $arrivals ? 'arr' : 'dep',
developer_mode => $developer_mode,
service => $service,
url => $hafas_url,
);
sub show_help {
my ($code) = @_;
print 'Usage: hafas-m [-d
] [-m ] [-t