From 4c77a16bbaa44e4df3c3697976b8b14ea5dd9e83 Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Sat, 27 Aug 2022 04:59:18 +0200 Subject: [PATCH] main: add -w to *enforce* wrapping --- main.py | 12 ++++++++---- wrapper/__init__.py | 10 +++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index e84f899..338a6a3 100755 --- a/main.py +++ b/main.py @@ -1,11 +1,13 @@ #!/usr/bin/env python3 import click -from traceback import format_exc as get_trace import subprocess +from traceback import format_exc as get_trace +from typing import Optional + from logger import logging, setup_logging, verbose_option -from wrapper import nowrapper_option +from wrapper import nowrapper_option, enforce_wrap from config import config, config_option, cmd_config from forwarding import cmd_forwarding from packages import cmd_packages @@ -23,12 +25,14 @@ from ssh import cmd_ssh @verbose_option @config_option @nowrapper_option -def cli(verbose: bool = False, config_file: str = None, no_wrapper: bool = False, error_shell: bool = False): +def cli(verbose: bool = False, config_file: str = None, wrapper_override: Optional[bool] = None, error_shell: bool = False): setup_logging(verbose) config.runtime['verbose'] = verbose - config.runtime['no_wrap'] = no_wrapper + config.runtime['no_wrap'] = wrapper_override is False config.runtime['error_shell'] = error_shell config.try_load_file(config_file) + if wrapper_override: + enforce_wrap() def main(): diff --git a/wrapper/__init__.py b/wrapper/__init__.py index 4b7a4c9..b680edd 100644 --- a/wrapper/__init__.py +++ b/wrapper/__init__.py @@ -51,10 +51,10 @@ def wrap_if_foreign_arch(arch: Arch): nowrapper_option = click.option( - '-W', - '--no-wrapper', - 'no_wrapper', + '-w/-W', + '--force-wrapper/--no-wrapper', + 'wrapper_override', is_flag=True, - default=False, - help='Disable the docker wrapper. Defaults to autodetection.', + default=None, + help='Force or disable the docker wrapper. Defaults to autodetection.', )