From 91d2cd3681cbc7c6ca3cc3b2a935e4967322a7fa Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Mon, 13 Mar 2023 05:54:36 +0100 Subject: [PATCH] config/cli: use wrapper.execute_without_exit() for prompt_profile_{flavour,device}() to avoid prompting in docker --- config/cli.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/config/cli.py b/config/cli.py index 237e434..e07e50b 100644 --- a/config/cli.py +++ b/config/cli.py @@ -7,6 +7,7 @@ from typing import Any, Iterable, Optional, Union from devices.device import get_devices from flavours.flavour import get_flavours +from wrapper import execute_without_exit from .scheme import Profile from .profile import PROFILE_EMPTY, PROFILE_DEFAULTS @@ -132,16 +133,22 @@ def prompt_choice(current: Optional[Any], key: str, choices: Iterable[Any], allo def prompt_profile_device(current: Optional[str], profile_name: str) -> tuple[str, bool]: - devices = get_devices() print(click.style("Pick your device!\nThese are the available devices:", bold=True)) + devices = execute_without_exit(get_devices, ['devices']) + if devices is None: + print("(wrapper mode, input for this field will not be checked for correctness)") + return prompt_config(text=f'{profile_name}.device', default=current) for dev in sorted(devices.keys()): print(f"{devices[dev]}\n") return prompt_choice(current, f'profiles.{profile_name}.device', devices.keys()) def prompt_profile_flavour(current: Optional[str], profile_name: str) -> tuple[str, bool]: - flavours = get_flavours() print(click.style("Pick your flavour!\nThese are the available flavours:", bold=True)) + flavours = execute_without_exit(get_flavours, ['flavours']) + if flavours is None: + print("(wrapper mode, input for this field will not be checked for correctness)") + return prompt_config(text=f'{profile_name}.flavour', default=current) for f in sorted(flavours.keys()): print(flavours[f]) return prompt_choice(current, f'profiles.{profile_name}.flavour', flavours.keys())