Unverified Commit f9678526 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

hafas-m: Add --raw-json option

parent 599ff9f5
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -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);
@@ -260,13 +261,19 @@ 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' ) )
		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