From c1ece2d6162d92f85e42a7befef522af5800088a Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Mon, 4 Oct 2021 20:16:59 +0200 Subject: [PATCH] main.py: add error shell flag for popping a shell on exceptions --- main.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index acc4345..c622075 100755 --- a/main.py +++ b/main.py @@ -2,6 +2,8 @@ import click from traceback import format_exc as get_trace +import subprocess + from logger import logging, setup_logging, verbose_option from wrapper import nowrapper_option from config import config, config_option, cmd_config @@ -17,13 +19,15 @@ from ssh import cmd_ssh @click.group() +@click.option('--error-shell', 'error_shell', is_flag=True, default=False, help='Spawn shell after error occurs') @verbose_option @config_option @nowrapper_option -def cli(verbose: bool = False, config_file: str = None, no_wrapper: bool = False): +def cli(verbose: bool = False, config_file: str = None, no_wrapper: bool = False, error_shell: bool = False): setup_logging(verbose) config.runtime['verbose'] = verbose config.runtime['no_wrap'] = no_wrapper + config.runtime['error_shell'] = error_shell config.try_load_file(config_file) @@ -32,6 +36,9 @@ def main(): return cli(prog_name='kupferbootstrap') except Exception: logging.fatal(get_trace()) + logging.info('Starting error shell. Type exit to quit.') + if config.runtime['error_shell']: + subprocess.call('/bin/bash') exit(1)