def _handle_error(error: McmdError, exit_on_error: bool, line_number: int): if exit_on_error: raise ScriptError.from_error(error, line_number) else: io.error(error.message) if error.info: io.info(error.info)
def _handle_error(error): io.error(error.message) if error.info: io.info(error.info) if isinstance(error, ScriptError): io.info('Script failed at line {}'.format(io.highlight(str(error.line)))) exit(1)
def _handle_error(error: McmdError, line_number: int, state: _ScriptExecutionState): if state.options.exit_on_error and not state.options.dry_run: raise ScriptError.from_error(error, line_number) else: sys.stderr.write('Error on line {}: '.format(str(line_number))) io.error(error.message) if error.info: io.info(error.info)
def _print_errors_and_exit(errors: List[ScriptValidationError]): io.error('The script contains errors') io.newline() errors.sort(key=lambda e: e.line_number) for error in errors: print(error.message) io.newline() exit(1)
def _ask(question, validation=None): answer = question.ask() if answer is None: # None result means that PyInquirer caught an InterruptException exit(0) elif validation: result = validation(answer) if result is not True: io.error(result) return _ask(question, validation) return answer
def history(args): if args.clear: io.start('Clearing history') hist.clear() else: lines = hist.read(args.number, include_fails=True) if len(lines) == 0: log.info('History is empty.') for line in lines: io.start(line[1]) if line[0]: io.succeed() else: io.error(None)
def _try_load_yaml(yaml: YAML, path: Path): try: return yaml.load(path) except YAMLError as e: io.error("There's an error in the configuration file: {}".format(e)) exit(1)