Skip to content

Commit

Permalink
feat(folder): add -y|--yes flag for purge and delete commands
Browse files Browse the repository at this point in the history
Refs: #469
  • Loading branch information
soywod committed Jan 10, 2025
1 parent f5695ca commit c79cabc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 17 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions src/folder/command/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ pub struct FolderDeleteCommand {

#[command(flatten)]
pub account: AccountNameFlag,

#[arg(long, short)]
pub yes: bool,
}

impl FolderDeleteCommand {
Expand All @@ -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()
Expand Down
13 changes: 9 additions & 4 deletions src/folder/command/purge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ pub struct FolderPurgeCommand {

#[command(flatten)]
pub account: AccountNameFlag,

#[arg(long, short)]
pub yes: bool,
}

impl FolderPurgeCommand {
Expand All @@ -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
Expand Down

0 comments on commit c79cabc

Please sign in to comment.