summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/cli/command.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask/cli/command.py')
-rw-r--r--src/leap/bitmask/cli/command.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/leap/bitmask/cli/command.py b/src/leap/bitmask/cli/command.py
index 95b0fe8d..15b864ff 100644
--- a/src/leap/bitmask/cli/command.py
+++ b/src/leap/bitmask/cli/command.py
@@ -57,7 +57,7 @@ class Command(object):
"about each command.")
commands = []
- def __init__(self, cfg):
+ def __init__(self, cfg, print_json=False):
self.cfg = cfg
color_init()
@@ -68,6 +68,7 @@ class Command(object):
self.data = []
if self.service:
self.data = [self.service]
+ self.print_json = print_json
def execute(self, raw_args):
self.parser = argparse.ArgumentParser(usage=self.usage,
@@ -112,7 +113,9 @@ class Command(object):
def _check_err(self, stuff, printer):
obj = json.loads(stuff[0])
- if not obj['error']:
+ if self.print_json:
+ print(json.dumps(obj, indent=2))
+ elif not obj['error']:
return printer(obj['result'])
else:
print Fore.RED + 'ERROR:' + '%s' % obj['error'] + Fore.RESET