summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2020-01-15 18:17:56 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2020-01-15 18:17:56 +0100
commit9cac3de3f8f9b9aa1246b4c63981f4a20cd381e9 (patch)
tree438ba50a8e9038784dbdeacb09f3e72a1fd98c0d
parent3c1742eb0675bf257ea5cc76b481efe37cda9f84 (diff)
Add --json option
-rwxr-xr-xbin/db-iris8
1 files changed, 8 insertions, 0 deletions
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;