From ce4738a1be0d86964ce8f7aec46617c1a1e08244 Mon Sep 17 00:00:00 2001 From: Grigori Fursin Date: Sat, 19 Oct 2024 18:50:47 +0200 Subject: [PATCH] V3.2.5 - CMX: improved logging - CMX: improved error handling (show module path and line number) - CMX: fixed bug when detecting unknown control flag - CMX: do not change output to json if -j or --json just print json in the end ... --- cm/CHANGES.md | 4 +++- cm/cmind/__init__.py | 2 +- cm/cmind/core.py | 26 ++++++++++++++++++++------ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/cm/CHANGES.md b/cm/CHANGES.md index 125eb93cb..57b892232 100644 --- a/cm/CHANGES.md +++ b/cm/CHANGES.md @@ -1,7 +1,9 @@ -## V3.2.4 +## V3.2.5 - CMX: improved logging - CMX: improved error handling (show module path and line number) - CMX: fixed bug when detecting unknown control flag + - CMX: do not change output to json if -j or --json + just print json in the end ... ## V3.2.3 - added --new_branch to `cm pull repo` and `cm checkout repo` diff --git a/cm/cmind/__init__.py b/cm/cmind/__init__.py index a99021d8c..f7f78e1f5 100644 --- a/cm/cmind/__init__.py +++ b/cm/cmind/__init__.py @@ -2,7 +2,7 @@ # # Written by Grigori Fursin -__version__ = "3.2.4.1" +__version__ = "3.2.5" from cmind.core import access from cmind.core import x diff --git a/cm/cmind/core.py b/cm/cmind/core.py index 8ecca0566..8e3577ce1 100644 --- a/cm/cmind/core.py +++ b/cm/cmind/core.py @@ -616,7 +616,7 @@ def access(self, i, out = None): if automation=='': return {'return':4, 'error':'automation was not specified'} else: - return {'return':4, 'error':'automation {} not found'.format(automation)} + return {'return':4, 'error':'automation "{}" not found'.format(automation)} # If no automation was found or we force common automation if use_common_automation or len(automation_lst)==0: @@ -857,6 +857,8 @@ def x(self, i, out = None): if control.pop('f', ''): i['f'] = True + output_json = (control.get('j', False) or control.get('json', False)) + self_time = control.get('time', False) if not x_was_called and self_time: import time @@ -978,7 +980,7 @@ def x(self, i, out = None): print ('') print ('CMX elapsed time: {:.3f} sec.'.format(self_time)) - if self.output == 'json': + if output_json: utils.dump_safe_json(r) # Restore directory of call @@ -1014,9 +1016,10 @@ def _x(self, i, control): if output == True: output = 'con' - # Check and force json console output - if control.get('j', False) or control.get('json', False): - output = 'json' +# Changed in v3.2.5 +# # Check and force json console output +# if control.get('j', False) or control.get('json', False): +# output = 'json' # Set self.output to the output of the very first access # to print error in the end if needed @@ -1050,6 +1053,17 @@ def _x(self, i, control): elif action == 'init' and automation == '': automation = 'core' + # Can add popular shortcuts + elif action == 'ff': + task = '' + if automation != '' and (' ' in automation or ',' in automation): + task = automation + if ' ' in automation: task = automation.replace(' ',',') + i['task'] = task + automation = 'flex.flow' + action = 'run' + i['automation'] = automation + i['action'] = action # Print basic help if action == '' extra_help = True if action == 'help' and automation == '' else False @@ -1291,7 +1305,7 @@ def _x(self, i, control): if automation=='': return {'return':4, 'error':'automation was not specified'} else: - return {'return':4, 'error':f'automation {automation} not found'} + return {'return':4, 'error':f'automation "{automation}" not found'} # If no automation was found or we force common automation loaded_common_automation = False