summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-08-03 23:27:18 +0200
committerDaniel Friesel <derf@finalrewind.org>2014-08-03 23:27:18 +0200
commit6c99da06378c1fb09ebcfff5ca12d1bc0f1397b5 (patch)
treec1c2cc25bd975d503422f648edcf4bd2d1b5ab82 /bin
parent9e453dec999ac7fd5fc7b526bb7fe04d9c20112e (diff)
efa: add --auto-url / --discover-and-print option
Diffstat (limited to 'bin')
-rwxr-xr-xbin/efa70
1 files changed, 43 insertions, 27 deletions
diff --git a/bin/efa b/bin/efa
index 3d8a377..89f3d81 100755
--- a/bin/efa
+++ b/bin/efa
@@ -157,6 +157,7 @@ GetOptions(
$opt,
qw{
arrive|a=s
+ auto-url|discover-and-print|A
bike|b
date|d=s
depart=s
@@ -221,7 +222,7 @@ if ( $opt->{exclude} ) {
$opt->{exclude} = [ split( /,/, join( ',', @{ $opt->{exclude} } ) ) ];
}
-if ( $opt->{discover} ) {
+if ( $opt->{discover} or $opt->{'auto-url'} ) {
for my $pair ( Travel::Routing::DE::EFA::get_efa_urls() ) {
my ( $url, $name ) = @{$pair};
$efa = eval {
@@ -249,36 +250,42 @@ if ( $opt->{discover} ) {
);
};
if ($efa) {
+ if ( $opt->{'auto-url'} ) {
+ last;
+ }
printf( "%-55s (%s)\n", $url, $name );
}
}
- exit 0;
+ if ( $opt->{'discover'} ) {
+ exit 0;
+ }
+}
+else {
+ $efa = eval {
+ Travel::Routing::DE::EFA->new(
+ efa_url => $efa_url,
+
+ origin => [ @from, $from_type ],
+ destination => [ @to, $to_type ],
+ via => ( @via ? [ @via, $via_type ] : undef ),
+
+ arrival_time => $opt->{arrive},
+ departure_time => $opt->{depart} // $opt->{time},
+ date => $opt->{date},
+ exclude => $opt->{exclude},
+ train_type => $opt->{include},
+ with_bike => $opt->{bike},
+
+ select_interchange_by => $opt->{prefer},
+ use_near_stops => $opt->{proximity},
+ walk_speed => $opt->{'walk-speed'},
+ max_interchanges => $opt->{'max-change'},
+ num_results => $opt->{'num-connections'},
+
+ lwp_options => { timeout => $opt->{timeout} },
+ );
+ };
}
-
-$efa = eval {
- Travel::Routing::DE::EFA->new(
- efa_url => $efa_url,
-
- origin => [ @from, $from_type ],
- destination => [ @to, $to_type ],
- via => ( @via ? [ @via, $via_type ] : undef ),
-
- arrival_time => $opt->{arrive},
- departure_time => $opt->{depart} // $opt->{time},
- date => $opt->{date},
- exclude => $opt->{exclude},
- train_type => $opt->{include},
- with_bike => $opt->{bike},
-
- select_interchange_by => $opt->{prefer},
- use_near_stops => $opt->{proximity},
- walk_speed => $opt->{'walk-speed'},
- max_interchanges => $opt->{'max-change'},
- num_results => $opt->{'num-connections'},
-
- lwp_options => { timeout => $opt->{timeout} },
- );
-};
check_for_error($@);
@@ -375,6 +382,15 @@ Journey end time (overrides --time/--depart)
Journey date
+=item B<-A>|B<--auto-url>|B<--discover-and-print>
+
+Probe all known EFA entry points for the specified connection. Print the first
+result which was not an error.
+
+Note that this may take a while and will not neccessarily return the best
+result. Also, using this option by default is not recommended, as it puts
+EFA services under considerable additional load.
+
=item B<-b>|B<--bike>
Choose connections allowing to carry a bike