1
0
Fork 0
mirror of https://github.com/soywod/himalaya.git synced 2025-04-22 17:23:27 +00:00

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

Refs: 
This commit is contained in:
Clément DOUIN 2025-01-10 16:28:53 +01:00
parent f5695cad53
commit c79cabc168
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72
4 changed files with 33 additions and 17 deletions

View file

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Added `-y|--yes` flag for `folder purge` and `folder delete` commands. [#469]
### Changed
- Put back `warn` the default log level. [#522]
@ -951,6 +955,7 @@ Few major concepts changed:
[0.2.0]: https://github.com/soywod/himalaya/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/soywod/himalaya/releases/tag/v0.1.0
[#469]: https://github.com/pimalaya/himalaya/issues/469
[#492]: https://github.com/pimalaya/himalaya/issues/492
[#496]: https://github.com/pimalaya/himalaya/issues/496
[#508]: https://github.com/pimalaya/himalaya/issues/508

17
Cargo.lock generated
View file

@ -1200,11 +1200,12 @@ dependencies = [
[[package]]
name = "email-lib"
version = "0.26.2"
source = "git+https://github.com/pimalaya/core#54aa97e39768ee8b6482fea7560bd15daadfa739"
source = "git+https://github.com/pimalaya/core#09c2283c54e37b99450a63b1285944456ba19ebc"
dependencies = [
"async-trait",
"chrono",
"chumsky",
"dirs",
"email-macros",
"email_address",
"futures",
@ -1828,7 +1829,7 @@ dependencies = [
[[package]]
name = "http-lib"
version = "0.1.0"
source = "git+https://github.com/pimalaya/core#54aa97e39768ee8b6482fea7560bd15daadfa739"
source = "git+https://github.com/pimalaya/core#09c2283c54e37b99450a63b1285944456ba19ebc"
dependencies = [
"thiserror 1.0.69",
"tokio",
@ -2274,7 +2275,7 @@ dependencies = [
[[package]]
name = "keyring-lib"
version = "1.0.2"
source = "git+https://github.com/pimalaya/core#54aa97e39768ee8b6482fea7560bd15daadfa739"
source = "git+https://github.com/pimalaya/core#09c2283c54e37b99450a63b1285944456ba19ebc"
dependencies = [
"keyring",
"once_cell",
@ -2599,7 +2600,7 @@ dependencies = [
[[package]]
name = "mml-lib"
version = "1.1.1"
source = "git+https://github.com/pimalaya/core#54aa97e39768ee8b6482fea7560bd15daadfa739"
source = "git+https://github.com/pimalaya/core#09c2283c54e37b99450a63b1285944456ba19ebc"
dependencies = [
"async-recursion",
"chumsky",
@ -2798,7 +2799,7 @@ dependencies = [
[[package]]
name = "oauth-lib"
version = "2.0.0"
source = "git+https://github.com/pimalaya/core#54aa97e39768ee8b6482fea7560bd15daadfa739"
source = "git+https://github.com/pimalaya/core#09c2283c54e37b99450a63b1285944456ba19ebc"
dependencies = [
"http-lib",
"oauth2",
@ -3082,7 +3083,7 @@ dependencies = [
[[package]]
name = "pgp-lib"
version = "1.0.0"
source = "git+https://github.com/pimalaya/core#54aa97e39768ee8b6482fea7560bd15daadfa739"
source = "git+https://github.com/pimalaya/core#09c2283c54e37b99450a63b1285944456ba19ebc"
dependencies = [
"async-recursion",
"futures",
@ -3261,7 +3262,7 @@ dependencies = [
[[package]]
name = "process-lib"
version = "1.0.0"
source = "git+https://github.com/pimalaya/core#54aa97e39768ee8b6482fea7560bd15daadfa739"
source = "git+https://github.com/pimalaya/core#09c2283c54e37b99450a63b1285944456ba19ebc"
dependencies = [
"serde",
"thiserror 1.0.69",
@ -3737,7 +3738,7 @@ dependencies = [
[[package]]
name = "secret-lib"
version = "1.0.0"
source = "git+https://github.com/pimalaya/core#54aa97e39768ee8b6482fea7560bd15daadfa739"
source = "git+https://github.com/pimalaya/core#09c2283c54e37b99450a63b1285944456ba19ebc"
dependencies = [
"keyring-lib",
"process-lib",

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()

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