mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
add new type 'simple' to cli _ask_confirmation
This commit is contained in:
parent
cbaa26f472
commit
ea3826fb8d
1 changed files with 20 additions and 4 deletions
24
src/app.py
24
src/app.py
|
@ -830,7 +830,7 @@ def _confirm_app_install(app, force=False):
|
||||||
if quality in ["danger", "thirdparty"]:
|
if quality in ["danger", "thirdparty"]:
|
||||||
_ask_confirmation("confirm_app_install_" + quality)
|
_ask_confirmation("confirm_app_install_" + quality)
|
||||||
else:
|
else:
|
||||||
_ask_confirmation("confirm_app_install_" + quality, soft=True)
|
_ask_confirmation("confirm_app_install_" + quality, kind="soft")
|
||||||
|
|
||||||
|
|
||||||
@is_unit_operation()
|
@is_unit_operation()
|
||||||
|
@ -2802,14 +2802,30 @@ def _assert_system_is_sane_for_app(manifest, when):
|
||||||
# FIXME: move this to Moulinette
|
# FIXME: move this to Moulinette
|
||||||
def _ask_confirmation(
|
def _ask_confirmation(
|
||||||
question: str,
|
question: str,
|
||||||
params: object = {},
|
params: dict = {},
|
||||||
soft: bool = False,
|
kind: str = "hard",
|
||||||
force: bool = False,
|
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":
|
if force or Moulinette.interface.type == "api":
|
||||||
return
|
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(
|
answer = Moulinette.prompt(
|
||||||
m18n.n(question, answers="Y/N", **params), color="yellow"
|
m18n.n(question, answers="Y/N", **params), color="yellow"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue