From 13bba1f4b8fced68acaaf50ca19a08b076f5f15f Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Sun, 21 Aug 2022 13:52:39 -0700 Subject: [PATCH] only show magic command fields if magic as used --- jc/cli.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/jc/cli.py b/jc/cli.py index b3ffff99..a53ad99d 100644 --- a/jc/cli.py +++ b/jc/cli.py @@ -458,16 +458,15 @@ def add_metadata_to(list_or_dict, """ run_timestamp = runtime.timestamp() - if not run_command: - magic_exit_code = None - meta_obj = { 'parser': parser_name, - 'magic_command': run_command, - 'magic_command_exit': magic_exit_code, 'timestamp': run_timestamp } + if run_command: + meta_obj['magic_command'] = run_command + meta_obj['magic_command_exit'] = magic_exit_code + if isinstance(list_or_dict, dict): if '_jc_meta' not in list_or_dict: list_or_dict['_jc_meta'] = {}