mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-16 20:57:53 +08:00
feat(folder): add -y|--yes flag for purge and delete commands
Refs: #469
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user