Loading bin/dbris +27 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ my ( $show_offers, $show_upsell_offers, $show_cross_offers ); my ( $first_class, $passengers ); my ( $developer_mode, $verbose ); my ( $json_output, $raw_json_output ); my $interactive = 1 * ( -t STDOUT and not( defined $ENV{TERM} and $ENV{TERM} eq 'dumb' ) ); my $use_cache = 1; my $use_colour = 'auto'; my $cache; Loading Loading @@ -73,6 +75,25 @@ GetOptions( ) or show_help(1); if ( $json_output or $raw_json_output ) { $interactive = 0; } sub req_start { my ($reason) = @_; if ($interactive) { $| = 1; print "Querying bahn.de ($reason) …"; } } 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 @@ -120,11 +141,13 @@ sub get_stop { $stopover_duration = $+{duration}; } req_start('stop lookup'); my $ris = Travel::Status::DE::DBRIS->new( cache => $cache, locationSearch => $stop, developer_mode => $developer_mode, ); req_stop(); if ( my $err = $ris->errstr ) { say STDERR "Request error while looking up '${stop}': ${err}"; exit 2; Loading Loading @@ -289,7 +312,9 @@ sub format_delay { return q{}; } req_start('main request'); my $ris = Travel::Routing::DE::DBRIS->new(%opt); req_stop(); if ( my $err = $ris->errstr ) { say STDERR "Request error: ${err}"; Loading Loading @@ -391,6 +416,7 @@ for my $connection ( $ris->connections ) { ); if ($show_offers) { req_start('offers'); my $offers_req = Travel::Routing::DE::DBRIS->new( developer_mode => $developer_mode, offers => { Loading @@ -399,6 +425,7 @@ for my $connection ( $ris->connections ) { passengers => $opt{passengers}, first_class => $opt{first_class}, ); req_stop(); if ( my $err = $offers_req->errstr ) { say STDERR "Request error while looking up offers: ${err}"; } Loading Loading
bin/dbris +27 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ my ( $show_offers, $show_upsell_offers, $show_cross_offers ); my ( $first_class, $passengers ); my ( $developer_mode, $verbose ); my ( $json_output, $raw_json_output ); my $interactive = 1 * ( -t STDOUT and not( defined $ENV{TERM} and $ENV{TERM} eq 'dumb' ) ); my $use_cache = 1; my $use_colour = 'auto'; my $cache; Loading Loading @@ -73,6 +75,25 @@ GetOptions( ) or show_help(1); if ( $json_output or $raw_json_output ) { $interactive = 0; } sub req_start { my ($reason) = @_; if ($interactive) { $| = 1; print "Querying bahn.de ($reason) …"; } } 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 @@ -120,11 +141,13 @@ sub get_stop { $stopover_duration = $+{duration}; } req_start('stop lookup'); my $ris = Travel::Status::DE::DBRIS->new( cache => $cache, locationSearch => $stop, developer_mode => $developer_mode, ); req_stop(); if ( my $err = $ris->errstr ) { say STDERR "Request error while looking up '${stop}': ${err}"; exit 2; Loading Loading @@ -289,7 +312,9 @@ sub format_delay { return q{}; } req_start('main request'); my $ris = Travel::Routing::DE::DBRIS->new(%opt); req_stop(); if ( my $err = $ris->errstr ) { say STDERR "Request error: ${err}"; Loading Loading @@ -391,6 +416,7 @@ for my $connection ( $ris->connections ) { ); if ($show_offers) { req_start('offers'); my $offers_req = Travel::Routing::DE::DBRIS->new( developer_mode => $developer_mode, offers => { Loading @@ -399,6 +425,7 @@ for my $connection ( $ris->connections ) { passengers => $opt{passengers}, first_class => $opt{first_class}, ); req_stop(); if ( my $err = $offers_req->errstr ) { say STDERR "Request error while looking up offers: ${err}"; } Loading