From ed55c1a7888b1b026851720dfccae4bd538a0b62 Mon Sep 17 00:00:00 2001 From: Dominic Fitzgerald Date: Fri, 23 Mar 2018 13:05:45 -0500 Subject: [PATCH] Better error if config is malformed --- operon/_cli/__init__.py | 2 +- operon/_cli/_completer.py | 2 +- operon/_cli/subcommands/configure.py | 4 ++-- operon/_util/__init__.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/operon/_cli/__init__.py b/operon/_cli/__init__.py index c416104..7ddb39f 100644 --- a/operon/_cli/__init__.py +++ b/operon/_cli/__init__.py @@ -12,7 +12,7 @@ def get_operon_subcommands(classes=False): ] ] if not classes: - return operon_subcommands + return [o.replace('_', '-') for o in operon_subcommands] return { operon_subcommand: fetch_subcommand_class(operon_subcommand) diff --git a/operon/_cli/_completer.py b/operon/_cli/_completer.py index 288b3f7..6eadb89 100644 --- a/operon/_cli/_completer.py +++ b/operon/_cli/_completer.py @@ -46,7 +46,7 @@ def completer(): stub=stub_token ) elif num_completed_tokens == 2: - if phrase[-2] in {'run', 'configure', 'show', 'uninstall'}: + if phrase[-2] in {'run', 'batch-run', 'configure', 'show', 'uninstall'}: completion_options = get_completion_options( options=get_pipeline_options(), stub=stub_token diff --git a/operon/_cli/subcommands/configure.py b/operon/_cli/subcommands/configure.py index cb0bfcd..a4e0831 100644 --- a/operon/_cli/subcommands/configure.py +++ b/operon/_cli/subcommands/configure.py @@ -274,8 +274,8 @@ def run(self, subcommand_args): except (KeyboardInterrupt, EOFError): sys.stderr.write('\nUser aborted configuration.\n') sys.exit(EXIT_CMD_SUCCESS) - except AttributeError: - raise MalformedPipelineConfigError('Something about the configuration is malformed') + except AttributeError as e: + raise MalformedPipelineConfigError('Something about the configuration is malformed: {}'.format(e)) # Write config out to file try: diff --git a/operon/_util/__init__.py b/operon/_util/__init__.py index cec5cc2..ad2db21 100644 --- a/operon/_util/__init__.py +++ b/operon/_util/__init__.py @@ -37,7 +37,7 @@ def execute_from_command_line(argv=None): parser.print_help() sys.exit(0) try: - operon_subcommand_classes[subcommand].run(argv[2:]) + operon_subcommand_classes[subcommand.replace('-', '_')].run(argv[2:]) except Exception as e: sys.stderr.write('Operon encountered an error when trying to execute {}:\n'.format(subcommand)) sys.stderr.write(str(e) + '\n')