Loading bin/dbris-m +27 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ my ( $json_output, $raw_json_output, $with_polyline ); my @output_args; my %show_output; my $num_route_entries = 3; my $interactive = 1 * -t STDOUT; my %known_mot = map { $_ => 1 } (qw(ICE EC_IC IR REGIONAL SBAHN BUS SCHIFF UBAHN TRAM ANRUFPFLICHTIG)); Loading Loading @@ -60,6 +61,24 @@ GetOptions( ) or show_help(1); if ( $json_output or $raw_json_output ) { $interactive = 0; } sub req_start { if ($interactive) { $| = 1; print 'Querying bahn.de …'; } } sub req_stop { if ($interactive) { print "\r\e[2K"; $| = 0; } } if ( $use_colour eq 'auto' and ( not -t STDOUT or ( defined $ENV{TERM} and $ENV{TERM} eq 'dumb' ) ) or $use_colour eq 'never' ) Loading Loading @@ -132,11 +151,13 @@ elsif ( $opt{station} =~ m{ [@] L = (?<eva> \d+ ) }x ) { }; } else { req_start(); my $status = Travel::Status::DE::DBRIS->new( cache => $cache, locationSearch => $opt{station}, developer_mode => $developer_mode, ); req_stop(); if ( my $err = $status->errstr ) { say STDERR "Request error while looking up '$opt{station}': ${err}"; exit 2; Loading Loading @@ -227,6 +248,7 @@ if ($mots) { } if ( $opt{station} and $train_type and $train_no ) { req_start(); my $status = Travel::Status::DE::DBRIS->new( cache => $cache, datetime => $opt{datetime}, Loading @@ -235,6 +257,7 @@ if ( $opt{station} and $train_type and $train_no ) { modes_of_transit => $opt{modes_of_transit} // [qw[ICE EC_IC IR REGIONAL SBAHN]], ); req_stop(); my $found = 0; for my $train ( $status->results ) { if ( Loading Loading @@ -324,7 +347,9 @@ sub format_delay { return q{}; } req_start(); my $status = Travel::Status::DE::DBRIS->new(%opt); req_stop(); if ( my $err = $status->errstr ) { say STDERR "Request error: ${err}"; Loading Loading @@ -537,11 +562,13 @@ elsif ( $opt{locationSearch} ) { } if ($train_no) { req_start(); $status = Travel::Status::DE::DBRIS->new( cache => $cache, developer_mode => $developer_mode, formation => $train_no ); req_stop(); if ($raw_json_output) { say JSON->new->convert_blessed->encode( $status->{raw_json} ); Loading Loading
bin/dbris-m +27 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ my ( $json_output, $raw_json_output, $with_polyline ); my @output_args; my %show_output; my $num_route_entries = 3; my $interactive = 1 * -t STDOUT; my %known_mot = map { $_ => 1 } (qw(ICE EC_IC IR REGIONAL SBAHN BUS SCHIFF UBAHN TRAM ANRUFPFLICHTIG)); Loading Loading @@ -60,6 +61,24 @@ GetOptions( ) or show_help(1); if ( $json_output or $raw_json_output ) { $interactive = 0; } sub req_start { if ($interactive) { $| = 1; print 'Querying bahn.de …'; } } sub req_stop { if ($interactive) { print "\r\e[2K"; $| = 0; } } if ( $use_colour eq 'auto' and ( not -t STDOUT or ( defined $ENV{TERM} and $ENV{TERM} eq 'dumb' ) ) or $use_colour eq 'never' ) Loading Loading @@ -132,11 +151,13 @@ elsif ( $opt{station} =~ m{ [@] L = (?<eva> \d+ ) }x ) { }; } else { req_start(); my $status = Travel::Status::DE::DBRIS->new( cache => $cache, locationSearch => $opt{station}, developer_mode => $developer_mode, ); req_stop(); if ( my $err = $status->errstr ) { say STDERR "Request error while looking up '$opt{station}': ${err}"; exit 2; Loading Loading @@ -227,6 +248,7 @@ if ($mots) { } if ( $opt{station} and $train_type and $train_no ) { req_start(); my $status = Travel::Status::DE::DBRIS->new( cache => $cache, datetime => $opt{datetime}, Loading @@ -235,6 +257,7 @@ if ( $opt{station} and $train_type and $train_no ) { modes_of_transit => $opt{modes_of_transit} // [qw[ICE EC_IC IR REGIONAL SBAHN]], ); req_stop(); my $found = 0; for my $train ( $status->results ) { if ( Loading Loading @@ -324,7 +347,9 @@ sub format_delay { return q{}; } req_start(); my $status = Travel::Status::DE::DBRIS->new(%opt); req_stop(); if ( my $err = $status->errstr ) { say STDERR "Request error: ${err}"; Loading Loading @@ -537,11 +562,13 @@ elsif ( $opt{locationSearch} ) { } if ($train_no) { req_start(); $status = Travel::Status::DE::DBRIS->new( cache => $cache, developer_mode => $developer_mode, formation => $train_no ); req_stop(); if ($raw_json_output) { say JSON->new->convert_blessed->encode( $status->{raw_json} ); Loading