diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-05-18 20:43:00 +0200 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-05-18 20:43:00 +0200 |
commit | 5a0b4737a8d15728a23a751315389ebde36263cf (patch) | |
tree | 0f695ef7208183be4613007fa2d3f6f939e04c54 | |
parent | bcd07b96d8a465381e6dc5584b94de6a78f822e0 (diff) |
dbris-m: make --(raw-)json work for carriage formation requests
-rwxr-xr-x | bin/dbris-m | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/bin/dbris-m b/bin/dbris-m index d5cc80f..eb0aebe 100755 --- a/bin/dbris-m +++ b/bin/dbris-m @@ -311,12 +311,12 @@ if ( my $err = $status->errstr ) { exit 2; } -if ($raw_json_output) { +if ( $raw_json_output and not $train_no ) { say JSON->new->convert_blessed->encode( $status->{raw_json} ); exit 0; } -if ($json_output) { +if ( $json_output and not $train_no ) { if ( $opt{journey} ) { say JSON->new->convert_blessed->encode( $status->result ); } @@ -364,7 +364,7 @@ if ( $opt{station} ) { } } } -elsif ( $opt{journey} ) { +elsif ( $opt{journey} and not( $raw_json_output or $json_output ) ) { my $trip = $status->result; my $max_name = max map { length( $_->name ) } $trip->route; @@ -463,6 +463,21 @@ if ($train_no) { formation => $train_no ); + if ($raw_json_output) { + say JSON->new->convert_blessed->encode( $status->{raw_json} ); + exit 0; + } + + if ($json_output) { + if ( $opt{journey} ) { + say JSON->new->convert_blessed->encode( $status->result ); + } + else { + say JSON->new->convert_blessed->encode( [ $status->results ] ); + } + exit 0; + } + my $wr = $status->result; if ( not $wr ) { |