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

add -m help / -m list support

parent 53a32113
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ use 5.010;
our $VERSION = '1.05';

use Getopt::Long qw(:config no_ignore_case);
use List::MoreUtils qw(uniq);
use List::Util qw(first max);
use Travel::Status::DE::HAFAS;

@@ -58,6 +59,16 @@ for my $type ( split( qr{,}, $types ) ) {
	}
}

if ( $train_type{help} or $train_type{list} or $train_type{'?'} ) {
	my @mots
	  = @{ Travel::Status::DE::HAFAS::get_service($service)->{productbits} };
	@mots = grep { $_ ne 'x' } @mots;
	@mots = uniq @mots;
	@mots = sort @mots;
	say join( "\n", @mots );
	exit 0;
}

my $status = Travel::Status::DE::HAFAS->new(
	date           => $date,
	language       => $language,
+9 −0
Original line number Diff line number Diff line
@@ -237,7 +237,16 @@ sub get_services {
	return @services;
}

# static
sub get_service {
	my ($service) = @_;

	$service //= 'DB';

	return $hafas_instance{$service};
}

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

	return %{ $hafas_instance{ $self->{active_service} } };