mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-02-22 13:15:44 -05:00
config/cli: use wrapper.execute_without_exit() for prompt_profile_{flavour,device}() to avoid prompting in docker
This commit is contained in:
parent
bc3fa84f58
commit
2408f00132
1 changed files with 9 additions and 2 deletions
|
@ -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(devices[dev])
|
||||
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())
|
||||
|
|
Loading…
Add table
Reference in a new issue