From 549a48049f70a0b1905f801d6332625adf4e133f Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 7 Sep 2016 12:04:53 +0200 Subject: ura-m: Support backend selection by symlink --- bin/ura-m | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/bin/ura-m b/bin/ura-m index e11b320..cea3acf 100755 --- a/bin/ura-m +++ b/bin/ura-m @@ -26,7 +26,7 @@ my $via; my ( $list_services, $service ); my $ura_base = 'http://ivu.aseag.de/interfaces/ura'; my $ura_version = 1; -my $script_name = (split(qr{/}, $0))[-1]; +my $script_name = ( split( qr{/}, $0 ) )[-1]; GetOptions( 'f|strftime=s' => \$strftime_format, @@ -53,6 +53,10 @@ if ( @ARGV != 1 ) { show_help(1); } +if ( not $service and $script_name ne 'ura-m' ) { + ($service) = ( $script_name =~ m{ ^ ( [^-]+ ) -m $ }x ); +} + # --line=foo,bar support @edata_pre = split( qr{,}, join( q{,}, @edata_pre ) ); @grep_lines = split( qr{,}, join( q{,}, @grep_lines ) ); @@ -94,7 +98,8 @@ my $status = Travel::Status::DE::URA->new( sub show_help { my ($code) = @_; - print "Usage: $script_name [-pV] [-o ] [-l ] [-v ] " + print + "Usage: $script_name [-pV] [-o ] [-l ] [-v ] " . "\n" . "See also: man ura-m\n"; @@ -302,6 +307,22 @@ B lists upcoming bus departures at the URA stop I. It only shows realtime data and has no knowledge of schedules or delays. Departures without such data may not appear at all. +=head1 OPERATOR SELECTION + +By default, B looks up departures for stops operated by ASEAG (Aachener +StraEenbahn und Energieversorgungs AG), so it only works for Aachen and +its vicinity. Other operators (and, thus, other areas) can be selected using +either the B<-s>/B<--service> option, the B<--ura-base> option, or the program +name. + +By creating a I-m symlink to B, it will default to the URA +interface operated by I, as if B<-s> I was specified. So, +for example, linking tfl-m to ura-m will request departures for TfL-operated +stops, and linking aseag-m to ura-m will request departures for ASEAG-operated +stops. + +Use the B<--list> option to get a list of supported backend services. + =head1 OPTIONS =over @@ -382,6 +403,7 @@ route output of B<-oa>, B<-ob>, B<-of>. Request departures for URA instance I, e.g. ASEAG (Aachen, Germany) or TfL (London, UK). Use B<--list> to get a list of supported URA instances. +Note that I is not case sensitive. =item B<-v>, B<--via> I -- cgit v1.2.3