Files
himalaya/src/imap/envelope/cli.rs
T
Clément DOUIN 662bd26eb1 refactor: remove composer and reader
Composers and readers did not work as expected. It is just not possible for
himalaya to spawn a command that spawns $EDITOR, piping and redirection cannot
satisfy all the needs. Either the $EDITOR does not spawn (hangs over), either
himalaya does not collect any output from edition. The simplest way is to use an
intermediate temp file, or use process substitution. For eg., using mml:

  mml compose >(himalaya message send)

You can also write into a file then feed himalaya with it.
2026-06-01 16:27:54 +02:00

62 lines
2.1 KiB
Rust

// This file is part of Himalaya, a CLI to manage emails.
//
// Copyright (C) 2022-2026 soywod <pimalaya.org@posteo.net>
//
// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU Affero General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
// details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use anyhow::Result;
use clap::Subcommand;
use pimalaya_cli::printer::Printer;
use crate::account::context::Account;
use crate::imap::{
client::ImapClient,
envelope::{
get::ImapEnvelopeGetCommand, list::ImapEnvelopeListCommand,
search::ImapEnvelopeSearchCommand, sort::ImapEnvelopeSortCommand,
thread::ImapEnvelopeThreadCommand,
},
};
/// Manage IMAP envelopes.
///
/// An envelope contains header information about a message such as
/// date, subject, from, to, cc, bcc, etc. This subcommand allows you
/// to get, list, search, sort, and thread envelopes.
#[derive(Debug, Subcommand)]
pub enum ImapEnvelopeCommand {
Get(ImapEnvelopeGetCommand),
List(ImapEnvelopeListCommand),
Search(ImapEnvelopeSearchCommand),
Sort(ImapEnvelopeSortCommand),
Thread(ImapEnvelopeThreadCommand),
}
impl ImapEnvelopeCommand {
pub fn execute(
self,
printer: &mut impl Printer,
account: &mut Account,
client: &mut ImapClient,
) -> Result<()> {
match self {
Self::Get(cmd) => cmd.execute(printer, account, client),
Self::List(cmd) => cmd.execute(printer, account, client),
Self::Search(cmd) => cmd.execute(printer, account, client),
Self::Sort(cmd) => cmd.execute(printer, account, client),
Self::Thread(cmd) => cmd.execute(printer, client),
}
}
}