Commit 2f8567d3 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

add -s/-u support

parent 0ebd8e6b
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ my $ignore_late = 0;
my $types       = q{};
my $language;
my $developer_mode;
my $list_services;
my ( $list_services, $service, $hafas_url );

my @output;

@@ -30,7 +30,9 @@ GetOptions(
	'l|lang=s'      => \$language,
	'L|ignore-late' => \$ignore_late,
	'm|mot=s'       => \$types,
	's|service=s'   => \$service,
	't|time=s'      => \$time,
	'u|url=s'       => \$hafas_url,
	'V|version'     => \&show_version,
	'devmode'       => \$developer_mode,
	'list'          => \$list_services,
@@ -62,6 +64,8 @@ my $status = Travel::Status::DE::HAFAS->new(
	time           => $time,
	mode           => $arrivals ? 'arr' : 'dep',
	developer_mode => $developer_mode,
	service        => $service,
	url            => $hafas_url,
);

sub show_help {
+13 −7
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ sub new {
	my $time = $conf{time} // strftime( '%H:%M',    localtime(time) );
	my $lang = $conf{language} // 'd';
	my $mode = $conf{mode}     // 'dep';
	my $service = $conf{service}  // 'DB';
	my $service = $conf{service};

	my %lwp_options = %{ $conf{lwp_options} // { timeout => 10 } };

@@ -43,6 +43,10 @@ sub new {
		confess('You need to specify a station');
	}

	if ( not defined $service and not defined $conf{url} ) {
		$service = 'DB';
	}

	my $ref = {
		active_service => $service,
		developer_mode => $conf{developer_mode},
@@ -60,7 +64,7 @@ sub new {

	$ref->set_productfilter;

	my $url = $hafas_instance{$service}{url} . '/' . $lang . 'n';
	my $url = ( $conf{url} // $hafas_instance{$service}{url} ) . "/${lang}n";

	$reply = $ua->post( $url, $ref->{post} );

@@ -100,9 +104,11 @@ sub set_productfilter {

	my $service = $self->{active_service};

	if ($service) {
		$self->{post}{productsFilter}
		  = '1' x ( scalar @{ $hafas_instance{$service}{productbits} } );
	}
}

sub check_input_error {
	my ($self) = @_;
@@ -207,7 +213,7 @@ sub get_services {
sub get_service {
	my ($self) = @_;

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

1;