mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-16 18:38:32 +03:00
pySim-shell: Add settable parameter on JSON pretty-printing
Change-Id: Ic095c96733de2b0f359bfe067cd719d38712faff
This commit is contained in:
@@ -72,6 +72,16 @@ class PysimApp(cmd2.Cmd):
|
||||
self.add_settable(cmd2.Settable('conserve_write', bool, 'Read and compare before write',
|
||||
onchange_cb=self._onchange_conserve_write))
|
||||
self.update_prompt()
|
||||
self.json_pretty_print = True
|
||||
self.add_settable(cmd2.Settable('json_pretty_print', bool, 'Pretty-Print JSON output'))
|
||||
|
||||
def poutput_json(self, data, force_no_pretty = False):
|
||||
"""line cmd2.putput() but for a json serializable dict."""
|
||||
if force_no_pretty or self.json_pretty_print == False:
|
||||
output = json.dumps(data)
|
||||
else:
|
||||
output = json.dumps(data, indent=4)
|
||||
self.poutput(output)
|
||||
|
||||
def _onchange_numeric_path(self, param_name, old, new):
|
||||
self.update_prompt()
|
||||
|
||||
Reference in New Issue
Block a user