From ea3826fb8d1da772510122aafe5a779d70684801 Mon Sep 17 00:00:00 2001 From: axolotle Date: Wed, 23 Nov 2022 16:00:35 +0100 Subject: [PATCH] add new type 'simple' to cli _ask_confirmation --- src/app.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/app.py b/src/app.py index de4636461..2974a69d8 100644 --- a/src/app.py +++ b/src/app.py @@ -830,7 +830,7 @@ def _confirm_app_install(app, force=False): if quality in ["danger", "thirdparty"]: _ask_confirmation("confirm_app_install_" + quality) else: - _ask_confirmation("confirm_app_install_" + quality, soft=True) + _ask_confirmation("confirm_app_install_" + quality, kind="soft") @is_unit_operation() @@ -2802,14 +2802,30 @@ def _assert_system_is_sane_for_app(manifest, when): # FIXME: move this to Moulinette def _ask_confirmation( question: str, - params: object = {}, - soft: bool = False, + params: dict = {}, + kind: str = "hard", force: bool = False, ): + """ + Ask confirmation + + Keyword argument: + question -- m18n key or string + params -- dict of values passed to the string formating + kind -- "hard": ask with "Yes, I understand", "soft": "Y/N", "simple": "press enter" + force -- Will not ask for confirmation + + """ if force or Moulinette.interface.type == "api": return - if soft: + if kind == "simple": + answer = Moulinette.prompt( + m18n.n(question, answers="Press enter to continue", **params), + color="yellow", + ) + answer = True + elif kind == "soft": answer = Moulinette.prompt( m18n.n(question, answers="Y/N", **params), color="yellow" )