From eec38a67fbb696b8d7c905539b1e837c876b091a Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 17 Aug 2014 16:31:02 +0200 Subject: efa: add -s / --service option --- bin/efa | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/bin/efa b/bin/efa index eb044d4..8942400 100755 --- a/bin/efa +++ b/bin/efa @@ -14,6 +14,7 @@ use Encode qw(decode); use Travel::Routing::DE::EFA; use Exception::Class; use Getopt::Long qw/:config no_ignore_case/; +use List::Util qw(first); our $VERSION = '2.07'; my $ignore_info = 'Fahrradmitnahme'; @@ -169,13 +170,14 @@ GetOptions( full-route|f help|h ignore-info|I:s + include|i=s list|l maps|M max-change|m=i num-connections|n=i prefer|P=s proximity|p - include|i=s + service|s=s time|t=s timeout=i to=s@{2} @@ -232,6 +234,20 @@ if ( $opt->{exclude} ) { $opt->{exclude} = [ split( /,/, join( ',', @{ $opt->{exclude} } ) ) ]; } +if ( $opt->{service} ) { + my $service = first { $_->{shortname} eq $opt->{service} } + Travel::Routing::DE::EFA::get_efa_urls(); + if ( not $service ) { + printf STDERR ( + "Error: Unknown service '%s'. See 'efa -l' for a " + . "list of supported service names\n", + $opt->{service} + ); + exit 1; + } + $efa_url = $service->{url}; +} + if ( $opt->{discover} or $opt->{'auto-url'} ) { for my $service ( Travel::Routing::DE::EFA::get_efa_urls() ) { $efa = eval { @@ -363,7 +379,8 @@ It sends the specified information to the online form and displays the results. It also supports other EFA services than L. B has a builtin list of EFA entry points which can be used with the -B<-A> and B<-D> options. You can also specify a custom URL using B<-u>. +B<-A> and B<-D> options. You can also specify a custom service using B<-u> I +or B<-s> I. However, the default EFA service is sufficient in most cases (even ICE connections all over Germany). @@ -435,7 +452,7 @@ these are not always available. =item B<-l>|B<--list> -List suddorted EFA services wit their URLs (see B<-u>) and abbreviations +List supported EFA services wit their URLs (see B<-u>) and abbreviations (see B<-s>). =item B<-m>|B<--max-change> I @@ -476,6 +493,11 @@ Prefer connections with less walking (at interchanges) Take stops close to the stop/start into account and possibly use them instead +=item B<-s>|B<--service> I + +Shortname of the EFA entry point. See Travel::Routing::DE::EFA(3pm) and +the B<-l> option for a list of services. + =item B<-i>|B<--include> I Include connections using trains of type I, where I may be: -- cgit v1.2.3