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

hafas-m documentation and -m help error handling

parent 52b55d2a
Loading
Loading
Loading
Loading
+33 −11
Original line number Diff line number Diff line
@@ -85,15 +85,20 @@ sub parse_mot_options {

	for my $type ( split( qr{,}, $types ) ) {
		if ( $type eq 'help' or $type eq 'list' or $type eq '?' ) {
			my @mots
			  = @{ Travel::Status::DE::HAFAS::get_service($service)
				  ->{productbits} };
			my $desc = Travel::Status::DE::HAFAS::get_service($service);
			  if ($desc) {
				my @mots = @{ $desc->{productbits} };
				@mots = grep { $_ ne 'x' } @mots;
				@mots = uniq @mots;
				@mots = sort @mots;
				say join( "\n", @mots );
				exit 0;
			}
			else {
				say STDERR 'no modes of transport known for this service';
				exit 1;
			}
		}
		elsif ( substr( $type, 0, 1 ) eq q{!} ) {
			push( @excluded_mots, substr( $type, 1 ) );
		}
@@ -213,8 +218,7 @@ departure screens installed at most main stations.

Show arrivals instead of departures, including trains ending at the specified
station. Note that this causes the output to display the start instead of
the end station and B<-f> to list all stops between start end
I<station>, not I<station> and end.
the end station.

=item B<-d>, B<--date> I<dd>.I<mm>.I<yyyy>

@@ -223,12 +227,16 @@ Date to list departures for. Default: today.
=item B<-l>, B<--lang> B<d>|B<e>|B<i>|B<n>

Set language used for additional information. Supports B<d>eutsch (default),
B<e>nglish, B<i>talian and dutch (B<n>).
B<e>nglish, B<i>talian and dutch (B<n>), depending on the used service.

=item B<-L>, B<--ignore-late>

Do not display delayed trains.

=item B<--list>

List known HAFAS installations. See also B<--service> and B<--url>.

=item B<-m>, B<--mot> I<motlist>

By default, B<hafas-m> shows all modes of transport arriving/departing at the
@@ -241,10 +249,24 @@ To show them exclusively, set I<motlist> to I<mot1>,I<mot2>,...

The I<mot> types depend on the used service. Use C<< -m help >> to list them.

=item B<-s>, B<--service> I<service>

Request arrivals/departures using the API provided by I<service>, defaults
to DB (Deutsche Bahn). See B<--list> for a list of known services.

=item B<-t>, B<--time> I<hh>:I<mm>

Time to list departures for.  Default: now.

=item B<-u>, B<--url> I<url>

Request arrivals/departures using the API entry point at I<url>, defaults to
C<< http://reiseauskunft.bahn.de/bin/bhftafel.exe >>. Note that the language
and output selection suffix (e.g. "/dn") must not be included here.

Again, see B<--list> for a list of known URLs. Unknown URLs are also
supported, though note that B<--mot> will not work when using this opton.

=item B<-V>, B<--version>

Show version information.
+4 −3
Original line number Diff line number Diff line
@@ -333,10 +333,11 @@ sub get_services {
sub get_service {
	my ($service) = @_;

	$service //= 'DB';

	if ( defined $service ) {
		return $hafas_instance{$service};
	}
	return;
}

sub get_active_service {
	my ($self) = @_;