diff options
Diffstat (limited to 'bin')
-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 ) { |