Loading bin/dbris-m +25 −10 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ use List::Util qw(max); use Travel::Status::DE::DBRIS; my $developer_mode; my $show_jid; my $use_cache = 1; my $cache; my ( $json_output, $raw_json_output ); Loading @@ -30,6 +31,7 @@ my $output_reset = -t STDOUT ? "\033[0m" : q{}; GetOptions( 'h|help' => sub { show_help(0) }, 'j|with-jid' => \$show_jid, 'V|version' => \&show_version, 'cache!' => \$use_cache, 'devmode' => \$developer_mode, Loading Loading @@ -158,22 +160,35 @@ if ($json_output) { if ( $opt{station} ) { my $max_line = max map { length( $_->line ) } $status->results; my $max_dest = max map { length( $_->dest_name ) } $status->results; my $max_dest = max map { length( $_->destination // q{} ) } $status->results; my $max_delay = max map { length( $_->delay // q{} ) } $status->results; my $max_platform = max map { length( $_->rt_platform // $_->platform // q{} ) } $status->results; $max_delay += 1; for my $result ( $status->results ) { printf( "%s %s %${max_line}s %${max_dest}s %s\n", "%s %s %${max_line}s %${max_dest}s %${max_platform}s\n", $result->is_cancelled ? '--:--' : $result->dep->strftime('%H:%M'), $result->delay ? sprintf( "(%+${max_delay}d)", $result->delay ) : q{ } x ( $max_delay + 2 ), $result->line, $result->dest_name, $result->destination // $result->via_last // q{???}, $result->rt_platform // $result->platform // q{} ); if ($show_jid) { say $result->id; } for my $message ( $result->messages ) { say $message->{text}; } if ( $show_jid or scalar $result->messages ) { say q{}; } } } elsif ( $opt{geoSearch} ) { Loading lib/Travel/Status/DE/DBRIS/Journey.pm +10 −3 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ use parent 'Class::Accessor'; our $VERSION = '0.01'; Travel::Status::DE::DBRIS::Journey->mk_ro_accessors( qw(type dep sched_dep rt_dep delay is_cancelled line stop_eva journey_id platform rt_platform dest_name via) qw(type dep sched_dep rt_dep delay is_cancelled line stop_eva id platform rt_platform destination via via_last) ); sub new { Loading @@ -21,12 +21,13 @@ sub new { my $ref = { type => $json->{verkehrmittel}{kurzText}, line => $json->{verkehrmittel}{mittelText}, journey_id => $json->{journeyID}, id => $json->{journeyId}, stop_eva => $json->{bahnhofsId}, dest_name => $json->{terminus}, destination => $json->{terminus}, platform => $json->{gleis}, rt_platform => $json->{ezGleis}, via => $json->{ueber}, via_last => ( $json->{ueber} // [] )->[-1], }; bless( $ref, $obj ); Loading Loading @@ -69,6 +70,12 @@ sub route { return @{ $self->{route} }; } sub messages { my ($self) = @_; return @{ $self->{messages} // [] }; } sub TO_JSON { my ($self) = @_; Loading Loading
bin/dbris-m +25 −10 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ use List::Util qw(max); use Travel::Status::DE::DBRIS; my $developer_mode; my $show_jid; my $use_cache = 1; my $cache; my ( $json_output, $raw_json_output ); Loading @@ -30,6 +31,7 @@ my $output_reset = -t STDOUT ? "\033[0m" : q{}; GetOptions( 'h|help' => sub { show_help(0) }, 'j|with-jid' => \$show_jid, 'V|version' => \&show_version, 'cache!' => \$use_cache, 'devmode' => \$developer_mode, Loading Loading @@ -158,22 +160,35 @@ if ($json_output) { if ( $opt{station} ) { my $max_line = max map { length( $_->line ) } $status->results; my $max_dest = max map { length( $_->dest_name ) } $status->results; my $max_dest = max map { length( $_->destination // q{} ) } $status->results; my $max_delay = max map { length( $_->delay // q{} ) } $status->results; my $max_platform = max map { length( $_->rt_platform // $_->platform // q{} ) } $status->results; $max_delay += 1; for my $result ( $status->results ) { printf( "%s %s %${max_line}s %${max_dest}s %s\n", "%s %s %${max_line}s %${max_dest}s %${max_platform}s\n", $result->is_cancelled ? '--:--' : $result->dep->strftime('%H:%M'), $result->delay ? sprintf( "(%+${max_delay}d)", $result->delay ) : q{ } x ( $max_delay + 2 ), $result->line, $result->dest_name, $result->destination // $result->via_last // q{???}, $result->rt_platform // $result->platform // q{} ); if ($show_jid) { say $result->id; } for my $message ( $result->messages ) { say $message->{text}; } if ( $show_jid or scalar $result->messages ) { say q{}; } } } elsif ( $opt{geoSearch} ) { Loading
lib/Travel/Status/DE/DBRIS/Journey.pm +10 −3 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ use parent 'Class::Accessor'; our $VERSION = '0.01'; Travel::Status::DE::DBRIS::Journey->mk_ro_accessors( qw(type dep sched_dep rt_dep delay is_cancelled line stop_eva journey_id platform rt_platform dest_name via) qw(type dep sched_dep rt_dep delay is_cancelled line stop_eva id platform rt_platform destination via via_last) ); sub new { Loading @@ -21,12 +21,13 @@ sub new { my $ref = { type => $json->{verkehrmittel}{kurzText}, line => $json->{verkehrmittel}{mittelText}, journey_id => $json->{journeyID}, id => $json->{journeyId}, stop_eva => $json->{bahnhofsId}, dest_name => $json->{terminus}, destination => $json->{terminus}, platform => $json->{gleis}, rt_platform => $json->{ezGleis}, via => $json->{ueber}, via_last => ( $json->{ueber} // [] )->[-1], }; bless( $ref, $obj ); Loading Loading @@ -69,6 +70,12 @@ sub route { return @{ $self->{route} }; } sub messages { my ($self) = @_; return @{ $self->{messages} // [] }; } sub TO_JSON { my ($self) = @_; Loading