Commit 4ab8c3cc authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Allow departure listing for an address / point of interest

parent 43f83fc7
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ use Getopt::Long qw(:config no_ignore_case);
use List::Util qw(max);
use Travel::Status::DE::VRR;

my ( $date, $time );
my ( $date, $time, $input_type );
my @output;

binmode( STDOUT, ':encoding(utf-8)' );
@@ -26,13 +26,18 @@ if ( @ARGV != 2 ) {
	show_help(1);
}

my ( $place, $station ) = @ARGV;
my ( $place, $input ) = @ARGV;

if ( $input =~ s{ ^ (?<type> address|poi|stop) : }{}x ) {
	$input_type = $+{type};
}

my $status = Travel::Status::DE::VRR->new(
	date  => $date,
	place => $place,
	name  => $station,
	name  => $input,
	time  => $time,
	type  => $input_type,
);

sub show_help {
+15 −4
Original line number Diff line number Diff line
@@ -17,6 +17,13 @@ sub new {
	my $mech = WWW::Mechanize->new();
	my @now  = localtime( time() );

	if ( not( $opt{place} and $opt{name} ) ) {
		confess('You need to specify a place and a name');
	}
	if ( $opt{type} and not( $opt{type} ~~ [qw[stop address poi]] ) ) {
		confess('type must be stop, address or poi');
	}

	my $self = {
		post => {
			command                => q{},
@@ -46,7 +53,7 @@ sub new {
			sessionID              => '0',
			submitButton           => 'anfordern',
			typeInfo_dm            => 'invalid',
			type_dm                => 'stop',
			type_dm                => $opt{type} // 'stop',
			useProxFootSearch      => '0',
			useRealtime            => '1',
		},
@@ -170,10 +177,14 @@ Arguments:

Name of the place/city

=item B<name> => I<stop name>
=item B<type> => B<address>|B<poi>|B<stop>

Type of the following I<name>.  B<poi> means "point of interest".  Defaults to
B<stop> (stop/station name).

=item B<name> => I<name>

Name of the stop to list departures for.  In future versions, this may also
support street or poi ("point of interest") names
address / poi / stop name to list departures for.

=back