turn folder arg into flag for message copy, move and delete cmds

This commit is contained in:
Clément DOUIN 2023-12-19 15:37:23 +01:00
parent c11f00d791
commit f398eb0d30
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72
4 changed files with 10 additions and 9 deletions

View file

@ -8,7 +8,7 @@ use crate::{
cache::arg::disable::CacheDisableFlag,
config::TomlConfig,
envelope::arg::ids::EnvelopeIdsArgs,
folder::arg::name::{SourceFolderNameArg, TargetFolderNameArg},
folder::arg::name::{SourceFolderNameOptionalFlag, TargetFolderNameArg},
printer::Printer,
};
@ -16,7 +16,7 @@ use crate::{
#[derive(Debug, Parser)]
pub struct MessageCopyCommand {
#[command(flatten)]
pub source_folder: SourceFolderNameArg,
pub source_folder: SourceFolderNameOptionalFlag,
#[command(flatten)]
pub target_folder: TargetFolderNameArg,

View file

@ -44,6 +44,6 @@ impl MessageDeleteCommand {
let ids = &self.envelopes.ids;
backend.delete_messages(folder, ids).await?;
printer.print("Message(s) successfully deleted from {from_folder} to {to_folder}!")
printer.print(format!("Message(s) successfully removed from {folder}!"))
}
}

View file

@ -8,7 +8,7 @@ use crate::{
cache::arg::disable::CacheDisableFlag,
config::TomlConfig,
envelope::arg::ids::EnvelopeIdsArgs,
folder::arg::name::{SourceFolderNameArg, TargetFolderNameArg},
folder::arg::name::{SourceFolderNameOptionalFlag, TargetFolderNameArg},
printer::Printer,
};
@ -16,7 +16,7 @@ use crate::{
#[derive(Debug, Parser)]
pub struct MessageMoveCommand {
#[command(flatten)]
pub source_folder: SourceFolderNameArg,
pub source_folder: SourceFolderNameOptionalFlag,
#[command(flatten)]
pub target_folder: TargetFolderNameArg,

View file

@ -26,11 +26,12 @@ pub struct FolderNameArg {
pub name: String,
}
/// The source folder name argument parser.
/// The optional source folder name flag parser.
#[derive(Debug, Parser)]
pub struct SourceFolderNameArg {
pub struct SourceFolderNameOptionalFlag {
/// The name of the source folder.
#[arg(name = "from-folder-name", value_name = "FROM")]
#[arg(long = "folder", short = 'f')]
#[arg(name = "source_folder_name", value_name = "SOURCE", default_value = INBOX)]
pub name: String,
}
@ -38,6 +39,6 @@ pub struct SourceFolderNameArg {
#[derive(Debug, Parser)]
pub struct TargetFolderNameArg {
/// The name of the target folder.
#[arg(name = "to-folder-name", value_name = "TO")]
#[arg(name = "target_folder_name", value_name = "TARGET")]
pub name: String,
}