Add pretty printer
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
+import json
+
import six
import sys
@@ -46,6 +48,15 @@ def dict_tabulate(dict_value, is_list_dict=False):
click.echo(tabulate(six.iteritems(dict_value)))
+def pprint(value):
+ """Prints as formatted JSON"""
+ click.echo(
+ json.dumps(value,
+ sort_keys=True,
+ indent=4,
+ separators=(',', ': ')))
+
+
class Printer(object):
COLORS = ['yellow', 'blue', 'magenta', 'green', 'cyan', 'red', 'white']
