Commit d87916ae authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

efa-m: Add (auto)discover support. may have unicode issues with some backends...

parent 1a0bbe9a
Loading
Loading
Loading
Loading
+40 −19
Original line number Diff line number Diff line
@@ -22,13 +22,15 @@ my ( $filter_via, $track_via );
my ( $timeout,       $developer_mode );
my ( @grep_lines,    @grep_platforms, @grep_mots );
my ( %edata,         @edata_pre );
my ( $list_services, $service );
my ( $list_services, $service, $discover_and_print, $discover );
my $efa;

@ARGV = map { decode( 'UTF-8', $_ ) } @ARGV;

GetOptions(
	'A|auto-url|discover-and-print' => \$discover_and_print,
	'd|date=s'                      => \$date,
	'D|discover'                    => \$discover,
	'h|help'                        => sub { show_help(0) },
	'l|line=s@'                     => \@grep_lines,
	'L|linelist'                    => \$list_lines,
@@ -313,6 +315,25 @@ sub show_results {
	return;
}

if ( $discover or $discover_and_print ) {
	for my $service_ref ( Travel::Status::DE::EFA::get_efa_urls() ) {
		$efa = new_efa_by_url( $service_ref->{url} );
		if ( $efa and not $efa->errstr ) {
			if ($discover_and_print) {
				last;
			}
			printf(
				"%s / %s (%s)\n   ->  efa-m -s %s %s\n\n",
				@{$service_ref}{qw(name shortname url shortname)},
				join( q{ }, map { "'$_'" } @ARGV ),
			);
		}
	}
	if ($discover) {
		exit 0;
	}
}

$efa = new_efa_by_url($efa_url);

if ( my $err = $efa->errstr ) {