diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2023-11-25 10:02:01 +0100 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2023-11-25 10:05:30 +0100 |
commit | 9d928f5cf6bb4ec857bf2b300894d5fee5ec61e2 (patch) | |
tree | ba370f49dcfcaebeac9012a636397a487320e739 /bin/hafas-m | |
parent | 6c2ebcb388c3ee99522b2afd9e83dcabe8eb4b61 (diff) |
Add support for stop-specific messages in journeys
Diffstat (limited to 'bin/hafas-m')
-rwxr-xr-x | bin/hafas-m | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/bin/hafas-m b/bin/hafas-m index 7df631f..42b0681 100755 --- a/bin/hafas-m +++ b/bin/hafas-m @@ -371,9 +371,24 @@ elsif ( $opt{journey} ) { $delay_fmt = $delay_len + 3; } + my $message_id = 1; + for my $stop ( $result->route ) { + my $msg_line = q{}; + for my $message ( $stop->messages ) { + if ( $message->ref_count > 0 + and $message->code ne + 'text.journeystop.product.or.direction.changes.stop.message' + and $message->text ne 'Halt entfällt' ) + { + if ( not $message->{id} ) { + $message->{id} = $message_id++; + } + $msg_line .= sprintf( ' (%d)', $message->{id} ); + } + } printf( -"%5s %s %5s %-${delay_fmt}s%${occupancy_len}s%-${occupancy_len}s %s%s\n", +"%5s %s %5s %-${delay_fmt}s%${occupancy_len}s%-${occupancy_len}s %s%s%s\n", $stop->arr_cancelled ? '--:--' : ( $stop->arr ? $stop->arr->strftime('%H:%M') : q{} ), ( $stop->arr and $stop->dep ) ? '→' : q{ }, @@ -385,7 +400,8 @@ elsif ( $opt{journey} ) { $stop->load->{SECOND} ? display_occupancy( $stop->load->{SECOND} ) : q{}, $stop->loc->name, - $stop->direction ? sprintf( ' → %s', $stop->direction ) : q{} + $stop->direction ? sprintf( ' → %s', $stop->direction ) : q{}, + $msg_line, ); } @@ -401,6 +417,16 @@ elsif ( $opt{journey} ) { } printf( "%s\n", $msg->text ); } + + for my $msg ( $status->messages ) { + if ( $msg->{id} ) { + say ''; + if ( $msg->short ) { + printf( "(%d) %s\n", $msg->{id}, $msg->short ); + } + printf( "(%d) %s\n", $msg->{id}, $msg->text ); + } + } exit 0; } |