From 74d956f92b07a2179cfc5a37266d33a5ee106534 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Fri, 1 Jan 2021 21:30:40 +0100 Subject: [PATCH] [enh] add --force to 'yunohost domain remove --remove-apps' --- data/actionsmap/yunohost.yml | 4 ++++ src/yunohost/domain.py | 14 ++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 6a90d3719..37ed79141 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -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: diff --git a/src/yunohost/domain.py b/src/yunohost/domain.py index c1a48c34e..879e47c6c 100644 --- a/src/yunohost/domain.py +++ b/src/yunohost/domain.py @@ -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)