summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2023-11-19 11:33:35 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2023-11-19 11:33:35 +0100
commitf9678526018e4b31e25a3d8435a5ffd60e0ebe4d (patch)
treede586fb581e91f68c622a142e5b39fb0ee722b82 /bin
parent599ff9f5f2f86fa499d5c8895ff683ba67ff395b (diff)
hafas-m: Add --raw-json option
Diffstat (limited to 'bin')
-rwxr-xr-xbin/hafas-m22
1 files changed, 17 insertions, 5 deletions
diff --git a/bin/hafas-m b/bin/hafas-m
index faa2a90..ff13932 100755
--- a/bin/hafas-m
+++ b/bin/hafas-m
@@ -18,7 +18,7 @@ my ( $date, $time, $language );
my $arrivals = 0;
my $types = q{};
my $developer_mode;
-my $json_output;
+my ( $json_output, $raw_json_output );
my ( $list_services, $service );
my ( @excluded_mots, @exclusive_mots );
@@ -40,6 +40,7 @@ GetOptions(
'V|version' => \&show_version,
'devmode' => \$developer_mode,
'json' => \$json_output,
+ 'raw-json' => \$raw_json_output,
'list' => \$list_services,
) or show_help(1);
@@ -259,14 +260,20 @@ sub display_occupancy {
if ( my $err = $status->errstr ) {
say STDERR "Request error: ${err}";
- if ( $status->errcode
- and ( $status->errcode eq 'H730' or $status->errcode eq 'LOCATION' ) )
+ if ( $status->errcode
+ and ( $status->errcode eq 'H730' or $status->errcode eq 'LOCATION' )
+ and not $raw_json_output )
{
show_similar_stops();
}
exit 2;
}
+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 );
@@ -457,8 +464,8 @@ Date to list departures for. Default: today.
=item B<--json>
-Print result(s) as JSON. This is a dump of internal data structures and not
-guaranteed to remain stable between minor versions. Please use the
+Print result(s) as JSON and exit. This is a dump of internal data structures
+and not guaranteed to remain stable between minor versions. Please use the
Travel::Status::DE::HAFAS(3pm) module if you need a proper API.
=item B<-l>, B<--language> I<language>
@@ -484,6 +491,11 @@ To show them exclusively, set I<motlist> to I<mot1>,I<mot2>,...
The I<mot> types depend on the used service. Use C<< -m help >> to list them.
+=item B<--raw-json>
+
+Print unprocessed HAFAS response as JSON and exit.
+Useful for debugging and development purposes.
+
=item B<-s>, B<--service> I<service>
Request arrivals/departures using the API provided by I<service>, defaults