From 9cac3de3f8f9b9aa1246b4c63981f4a20cd381e9 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 15 Jan 2020 18:17:56 +0100 Subject: Add --json option --- bin/db-iris | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/db-iris b/bin/db-iris index 8b858c3..c0b5a2a 100755 --- a/bin/db-iris +++ b/bin/db-iris @@ -12,6 +12,7 @@ use DateTime; use DateTime::Format::Strptime; use Encode qw(decode); use Getopt::Long qw(:config no_ignore_case bundling); +use JSON; use List::Util qw(first max); use List::MoreUtils qw(none); use Travel::Status::DE::IRIS; @@ -26,6 +27,7 @@ my $with_related = 1; my ( $filter_via, $track_via, $status_via ); my ( @grep_class, @grep_type, @grep_platform ); my ( %edata, @edata_pre ); +my $json_output = 0; my @output; @@ -47,6 +49,7 @@ GetOptions( 'V|track-via=s' => \$track_via, 'x|exact|no-related' => sub { $with_related = 0 }, 'devmode' => \$developer_mode, + 'json' => \$json_output, 'version' => \&show_version, ) or show_help(1); @@ -413,6 +416,11 @@ if ( $status_via and $status_via->warnstr ) { sanitize_options(); +if ($json_output) { + say JSON->new->convert_blessed->encode( [ $status->results ] ); + exit 0; +} + for my $d ( $status->results() ) { my @via; -- cgit v1.2.3