[enh] add --force to 'yunohost domain remove --remove-apps'

This commit is contained in:
Laurent Peuch 2021-01-01 21:30:40 +01:00
parent 865265ea54
commit 74d956f92b
2 changed files with 12 additions and 6 deletions

View file

@ -452,6 +452,10 @@ domain:
full: --remove-apps
help: Remove apps installed on the domain
action: store_true
-f:
full: --force
help: Do not ask confirmation to remove apps
action: store_true
### domain_dns_conf()
dns-conf:

View file

@ -179,7 +179,8 @@ def domain_remove(operation_logger, domain, remove_apps=False, force=False):
Keyword argument:
domain -- Domain to delete
remove_apps -- Remove applications installed on the domain
force -- Force the domain removal
force -- Force the domain removal and don't not ask confirmation to
remove apps if remove_apps is specified
"""
from yunohost.hook import hook_callback
@ -211,11 +212,12 @@ def domain_remove(operation_logger, domain, remove_apps=False, force=False):
if apps_on_that_domain:
if remove_apps:
answer = msignals.prompt(m18n.n('domain_remove_confirm_apps_removal',
apps="\n".join([x[1] for x in apps_on_that_domain]),
answers='y/N'), color="yellow")
if answer.upper() != "Y":
raise YunohostError("aborting")
if not yes:
answer = msignals.prompt(m18n.n('domain_remove_confirm_apps_removal',
apps="\n".join([x[1] for x in apps_on_that_domain]),
answers='y/N'), color="yellow")
if answer.upper() != "Y":
raise YunohostError("aborting")
for app, _ in apps_on_that_domain:
app_remove(app)