main.py: add error shell flag for popping a shell on exceptions
This commit is contained in:
parent
0b2caa02af
commit
c1ece2d616
1 changed files with 8 additions and 1 deletions
9
main.py
9
main.py
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
import click
|
import click
|
||||||
from traceback import format_exc as get_trace
|
from traceback import format_exc as get_trace
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from logger import logging, setup_logging, verbose_option
|
from logger import logging, setup_logging, verbose_option
|
||||||
from wrapper import nowrapper_option
|
from wrapper import nowrapper_option
|
||||||
from config import config, config_option, cmd_config
|
from config import config, config_option, cmd_config
|
||||||
|
@ -17,13 +19,15 @@ from ssh import cmd_ssh
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
|
@click.option('--error-shell', 'error_shell', is_flag=True, default=False, help='Spawn shell after error occurs')
|
||||||
@verbose_option
|
@verbose_option
|
||||||
@config_option
|
@config_option
|
||||||
@nowrapper_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)
|
setup_logging(verbose)
|
||||||
config.runtime['verbose'] = verbose
|
config.runtime['verbose'] = verbose
|
||||||
config.runtime['no_wrap'] = no_wrapper
|
config.runtime['no_wrap'] = no_wrapper
|
||||||
|
config.runtime['error_shell'] = error_shell
|
||||||
config.try_load_file(config_file)
|
config.try_load_file(config_file)
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,6 +36,9 @@ def main():
|
||||||
return cli(prog_name='kupferbootstrap')
|
return cli(prog_name='kupferbootstrap')
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.fatal(get_trace())
|
logging.fatal(get_trace())
|
||||||
|
logging.info('Starting error shell. Type exit to quit.')
|
||||||
|
if config.runtime['error_shell']:
|
||||||
|
subprocess.call('/bin/bash')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue