feat(folder): add -y|--yes flag for purge and delete commands

Refs: #469
This commit is contained in:
Clément DOUIN
2025-01-10 16:28:53 +01:00
parent f5695cad53
commit c79cabc168
4 changed files with 33 additions and 17 deletions
+10 -5
View File
@@ -27,6 +27,9 @@ pub struct FolderDeleteCommand {
#[command(flatten)]
pub account: AccountNameFlag,
#[arg(long, short)]
pub yes: bool,
}
impl FolderDeleteCommand {
@@ -35,12 +38,14 @@ impl FolderDeleteCommand {
let folder = &self.folder.name;
let confirm = format!("Do you really want to delete the folder {folder}");
let confirm = format!("{confirm}? All emails will be definitely deleted.");
if !self.yes {
let confirm = format!("Do you really want to delete the folder {folder}");
let confirm = format!("{confirm}? All emails will be definitely deleted.");
if !prompt::bool(confirm, false)? {
process::exit(0);
};
if !prompt::bool(confirm, false)? {
process::exit(0);
};
}
let (toml_account_config, account_config) = config
.clone()
+9 -4
View File
@@ -24,6 +24,9 @@ pub struct FolderPurgeCommand {
#[command(flatten)]
pub account: AccountNameFlag,
#[arg(long, short)]
pub yes: bool,
}
impl FolderPurgeCommand {
@@ -32,11 +35,13 @@ impl FolderPurgeCommand {
let folder = &self.folder.name;
let confirm = format!("Do you really want to purge the folder {folder}");
let confirm = format!("{confirm}? All emails will be definitely deleted.");
if !self.yes {
let confirm = format!("Do you really want to purge the folder {folder}");
let confirm = format!("{confirm}? All emails will be definitely deleted.");
if !prompt::bool(confirm, false)? {
process::exit(0);
if !prompt::bool(confirm, false)? {
process::exit(0);
};
};
let (toml_account_config, account_config) = config