summaryrefslogtreecommitdiff
path: root/bin/hafas-m
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-06-13 10:29:14 +0200
committerDaniel Friesel <derf@finalrewind.org>2020-06-13 10:29:14 +0200
commit503d31430696a55a5b097eb2107155f1ba42f5e0 (patch)
tree142da931733b113ad842e121db128bf0de385f50 /bin/hafas-m
parent187e17546a8395476a119bf94d50f0c9ef780338 (diff)
store more message details
Diffstat (limited to 'bin/hafas-m')
-rwxr-xr-xbin/hafas-m32
1 files changed, 26 insertions, 6 deletions
diff --git a/bin/hafas-m b/bin/hafas-m
index 048e077..7b2491b 100755
--- a/bin/hafas-m
+++ b/bin/hafas-m
@@ -146,10 +146,14 @@ sub display_result {
for my $line (@lines) {
- my $d = $line->[6];
- if ( $d->messages ) {
- print "\n";
- for my $msg ( $d->messages ) {
+ my $d = $line->[6];
+ my $first_message = 1;
+ for my $msg ( $d->messages ) {
+ if ( $msg->{ref_count} == 1 ) {
+ if ($first_message) {
+ print "\n";
+ $first_message = 0;
+ }
printf( "# %s\n", $msg );
}
}
@@ -175,12 +179,28 @@ if ( my $err = $status->errstr ) {
exit 2;
}
-for my $d ( $status->results() ) {
+my $message_id = 1;
+for my $m ( $status->messages ) {
+ if ( $m->{ref_count} > 1 ) {
+ $m->{id} = $message_id++;
+ printf( "# (%d) %s\n# %s\n\n", $m->{id}, $m->{header}, $m->{lead} );
+ }
+}
+
+for my $d ( $status->results ) {
if ( $ignore_late and $d->delay ) {
next;
}
+ my $info_line = $d->info // q{};
+
+ for my $message ( $d->messages ) {
+ if ( $message->{ref_count} > 1 ) {
+ $info_line = sprintf( '(%d) %s', $message->{id}, $info_line );
+ }
+ }
+
push(
@output,
[
@@ -191,7 +211,7 @@ for my $d ( $status->results() ) {
$d->train,
$d->route_end,
( $d->platform // q{} ) . ( $d->is_changed_platform ? ' !' : q{} ),
- $d->info,
+ $info_line,
$d
]
);