mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-17 21:37:55 +08:00
chore: clean
This commit is contained in:
@@ -40,7 +40,8 @@ impl MaildirEnvelopeListCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, client: MaildirClient) -> Result<()> {
|
||||
let maildir = client.resolve_maildir(&self.maildir.inner)?;
|
||||
|
||||
let messages = client.list_messages(maildir)?;
|
||||
let entries: Vec<_> = client.list_entries(maildir)?.into_iter().collect();
|
||||
let messages = client.read_entries_par(&entries)?;
|
||||
|
||||
let mut envelopes = Vec::with_capacity(messages.len());
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use io_maildir::flag::Flags;
|
||||
use io_maildir::flag::MaildirFlags;
|
||||
use pimalaya_cli::printer::{Message, Printer};
|
||||
|
||||
use crate::maildir::{
|
||||
@@ -37,7 +37,7 @@ pub struct MaildirFlagAddCommand {
|
||||
|
||||
#[command(flatten)]
|
||||
pub maildir: MaildirPathFlag,
|
||||
/// Flag(s) to add to the message
|
||||
/// MaildirFlag(s) to add to the message
|
||||
#[arg(long = "flag", short, num_args = 1..)]
|
||||
pub flags: Vec<FlagArg>,
|
||||
}
|
||||
@@ -46,12 +46,12 @@ impl MaildirFlagAddCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, client: MaildirClient) -> Result<()> {
|
||||
let maildir = client.resolve_maildir(&self.maildir.inner)?;
|
||||
|
||||
let flags = Flags::from_iter(self.flags.into_iter().map(Into::into));
|
||||
let flags = MaildirFlags::from_iter(self.flags.into_iter().map(Into::into));
|
||||
|
||||
for id in self.ids.inner {
|
||||
client.add_flags(maildir.clone(), id, flags.clone())?;
|
||||
}
|
||||
|
||||
printer.out(Message::new("Flag(s) successfully added"))
|
||||
printer.out(Message::new("MaildirFlag(s) successfully added"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use clap::ValueEnum;
|
||||
use io_maildir::flag::Flag;
|
||||
use io_maildir::flag::MaildirFlag;
|
||||
|
||||
#[derive(Clone, Debug, ValueEnum)]
|
||||
#[clap(rename_all = "kebab-case")]
|
||||
@@ -29,15 +29,15 @@ pub enum FlagArg {
|
||||
Flagged,
|
||||
}
|
||||
|
||||
impl From<FlagArg> for Flag {
|
||||
impl From<FlagArg> for MaildirFlag {
|
||||
fn from(flag: FlagArg) -> Self {
|
||||
match flag {
|
||||
FlagArg::Passed => Flag::Passed,
|
||||
FlagArg::Replied => Flag::Replied,
|
||||
FlagArg::Seen => Flag::Seen,
|
||||
FlagArg::Trashed => Flag::Trashed,
|
||||
FlagArg::Draft => Flag::Draft,
|
||||
FlagArg::Flagged => Flag::Flagged,
|
||||
FlagArg::Passed => MaildirFlag::Passed,
|
||||
FlagArg::Replied => MaildirFlag::Replied,
|
||||
FlagArg::Seen => MaildirFlag::Seen,
|
||||
FlagArg::Trashed => MaildirFlag::Trashed,
|
||||
FlagArg::Draft => MaildirFlag::Draft,
|
||||
FlagArg::Flagged => MaildirFlag::Flagged,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ use std::fmt;
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use comfy_table::{Cell, ContentArrangement, Row, Table};
|
||||
use io_maildir::flag::Flag;
|
||||
use io_maildir::flag::MaildirFlag;
|
||||
use pimalaya_cli::printer::Printer;
|
||||
use serde::Serialize;
|
||||
|
||||
@@ -40,12 +40,12 @@ impl MaildirFlagListCommand {
|
||||
preset: client.account.table_preset().to_string(),
|
||||
arrangement: client.account.table_arrangement(),
|
||||
flags: vec![
|
||||
FlagRow::new(Flag::Passed),
|
||||
FlagRow::new(Flag::Replied),
|
||||
FlagRow::new(Flag::Seen),
|
||||
FlagRow::new(Flag::Trashed),
|
||||
FlagRow::new(Flag::Draft),
|
||||
FlagRow::new(Flag::Flagged),
|
||||
FlagRow::new(MaildirFlag::Passed),
|
||||
FlagRow::new(MaildirFlag::Replied),
|
||||
FlagRow::new(MaildirFlag::Seen),
|
||||
FlagRow::new(MaildirFlag::Trashed),
|
||||
FlagRow::new(MaildirFlag::Draft),
|
||||
FlagRow::new(MaildirFlag::Flagged),
|
||||
],
|
||||
};
|
||||
|
||||
@@ -69,7 +69,7 @@ pub struct FlagRow {
|
||||
}
|
||||
|
||||
impl FlagRow {
|
||||
pub fn new(flag: Flag) -> Self {
|
||||
pub fn new(flag: MaildirFlag) -> Self {
|
||||
Self {
|
||||
code: flag.to_string(),
|
||||
name: format!("{flag:?}"),
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use io_maildir::flag::Flags;
|
||||
use io_maildir::flag::MaildirFlags;
|
||||
use pimalaya_cli::printer::{Message, Printer};
|
||||
|
||||
use crate::maildir::{
|
||||
@@ -37,7 +37,7 @@ pub struct MaildirFlagRemoveCommand {
|
||||
|
||||
#[command(flatten)]
|
||||
pub maildir: MaildirPathFlag,
|
||||
/// Flag(s) to remove to the message
|
||||
/// MaildirFlag(s) to remove to the message
|
||||
#[arg(long = "flag", short, num_args = 1..)]
|
||||
pub flags: Vec<FlagArg>,
|
||||
}
|
||||
@@ -46,12 +46,12 @@ impl MaildirFlagRemoveCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, client: MaildirClient) -> Result<()> {
|
||||
let maildir = client.resolve_maildir(&self.maildir.inner)?;
|
||||
|
||||
let flags = Flags::from_iter(self.flags.into_iter().map(Into::into));
|
||||
let flags = MaildirFlags::from_iter(self.flags.into_iter().map(Into::into));
|
||||
|
||||
for id in self.ids.inner {
|
||||
client.remove_flags(maildir.clone(), id, flags.clone())?;
|
||||
}
|
||||
|
||||
printer.out(Message::new("Flag(s) successfully removed"))
|
||||
printer.out(Message::new("MaildirFlag(s) successfully removed"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use io_maildir::flag::Flags;
|
||||
use io_maildir::flag::MaildirFlags;
|
||||
use pimalaya_cli::printer::{Message, Printer};
|
||||
|
||||
use crate::maildir::{
|
||||
@@ -37,7 +37,7 @@ pub struct MaildirFlagSetCommand {
|
||||
|
||||
#[command(flatten)]
|
||||
pub maildir: MaildirPathFlag,
|
||||
/// Flag(s) to set to the message
|
||||
/// MaildirFlag(s) to set to the message
|
||||
#[arg(long = "flag", short, num_args = 1..)]
|
||||
pub flags: Vec<FlagArg>,
|
||||
}
|
||||
@@ -46,12 +46,12 @@ impl MaildirFlagSetCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, client: MaildirClient) -> Result<()> {
|
||||
let maildir = client.resolve_maildir(&self.maildir.inner)?;
|
||||
|
||||
let flags = Flags::from_iter(self.flags.into_iter().map(Into::into));
|
||||
let flags = MaildirFlags::from_iter(self.flags.into_iter().map(Into::into));
|
||||
|
||||
for id in self.ids.inner {
|
||||
client.set_flags(maildir.clone(), id, flags.clone())?;
|
||||
}
|
||||
|
||||
printer.out(Message::new("Flag(s) successfully changed"))
|
||||
printer.out(Message::new("MaildirFlag(s) successfully changed"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ use std::{
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use io_maildir::flag::Flags;
|
||||
use io_maildir::flag::MaildirFlags;
|
||||
use pimalaya_cli::printer::Printer;
|
||||
use serde::Serialize;
|
||||
|
||||
@@ -75,7 +75,7 @@ impl MaildirMessageSaveCommand {
|
||||
.join("\r\n")
|
||||
};
|
||||
|
||||
let flags = Flags::from_iter(self.flags.into_iter().map(Into::into));
|
||||
let flags = MaildirFlags::from_iter(self.flags.into_iter().map(Into::into));
|
||||
|
||||
let (id, path) = client.store(maildir, self.subdir.into(), flags, msg.into_bytes())?;
|
||||
let path = PathBuf::from(path.into_string());
|
||||
|
||||
@@ -72,15 +72,15 @@ impl FlagArg {
|
||||
}
|
||||
|
||||
#[cfg(feature = "maildir")]
|
||||
impl From<&FlagArg> for io_maildir::flag::Flag {
|
||||
impl From<&FlagArg> for io_maildir::flag::MaildirFlag {
|
||||
fn from(flag: &FlagArg) -> Self {
|
||||
use io_maildir::flag::Flag;
|
||||
use io_maildir::flag::MaildirFlag;
|
||||
|
||||
match flag {
|
||||
FlagArg::Seen => Flag::Seen,
|
||||
FlagArg::Answered => Flag::Replied,
|
||||
FlagArg::Flagged => Flag::Flagged,
|
||||
FlagArg::Draft => Flag::Draft,
|
||||
FlagArg::Seen => MaildirFlag::Seen,
|
||||
FlagArg::Answered => MaildirFlag::Replied,
|
||||
FlagArg::Flagged => MaildirFlag::Flagged,
|
||||
FlagArg::Draft => MaildirFlag::Draft,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user