Skip to content

Commit

Permalink
Merge pull request #412 from fosterseth/feat_receptorctl_status_json
Browse files Browse the repository at this point in the history
add --json to status command to print json
  • Loading branch information
shanemcd authored Sep 2, 2021
2 parents 6a4fbbc + b1c730b commit 7cb98c7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions receptorctl/receptorctl/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import tty
import termios
import click
import json
from pprint import pprint
from functools import partial
import dateutil.parser
Expand Down Expand Up @@ -49,10 +50,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(json.dumps(status))
return
node_id = status.pop('NodeID')
print(f"Node ID: {node_id}")
version = status.pop('Version')
Expand Down

0 comments on commit 7cb98c7

Please sign in to comment.