From 1d311b97c7ca260c254d10625ec2fc13c15e2548 Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Thu, 2 Sep 2021 12:39:57 -0400 Subject: [PATCH 1/2] add --json to status command to print json --- receptorctl/receptorctl/cli.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/receptorctl/receptorctl/cli.py b/receptorctl/receptorctl/cli.py index 93bf42a3a..d376f7796 100644 --- a/receptorctl/receptorctl/cli.py +++ b/receptorctl/receptorctl/cli.py @@ -49,10 +49,13 @@ def get_rc(ctx): @cli.command(help="Show the status of the Receptor network.") @click.pass_context -def status(ctx): +@click.option('--json', 'printjson', help="Print as JSON", is_flag=True) +def status(ctx, printjson): rc = get_rc(ctx) status = rc.simple_command("status") - + if printjson: + print(status) + return node_id = status.pop('NodeID') print(f"Node ID: {node_id}") version = status.pop('Version') From b1c730bce30cf183347b47f20e66505bdbff7f6a Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Thu, 2 Sep 2021 13:02:58 -0400 Subject: [PATCH 2/2] json dump --- receptorctl/receptorctl/cli.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/receptorctl/receptorctl/cli.py b/receptorctl/receptorctl/cli.py index d376f7796..0116a8f34 100644 --- a/receptorctl/receptorctl/cli.py +++ b/receptorctl/receptorctl/cli.py @@ -6,6 +6,7 @@ import tty import termios import click +import json from pprint import pprint from functools import partial import dateutil.parser @@ -54,7 +55,7 @@ def status(ctx, printjson): rc = get_rc(ctx) status = rc.simple_command("status") if printjson: - print(status) + print(json.dumps(status)) return node_id = status.pop('NodeID') print(f"Node ID: {node_id}")