mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-17 13:17:55 +08:00
fix editor command hanging, add --preview flag for msg read cmd
This commit is contained in:
@@ -11,7 +11,9 @@ use crate::{
|
||||
|
||||
/// Read a message.
|
||||
///
|
||||
/// This command allows you to read a message.
|
||||
/// This command allows you to read a message. When reading a message,
|
||||
/// the "seen" flag is automatically applied to the corresponding
|
||||
/// envelope. To prevent this behaviour, use the --preview flag.
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct MessageReadCommand {
|
||||
#[command(flatten)]
|
||||
@@ -20,6 +22,11 @@ pub struct MessageReadCommand {
|
||||
#[command(flatten)]
|
||||
pub envelopes: EnvelopeIdsArgs,
|
||||
|
||||
/// Read the message without applying the "seen" flag to its
|
||||
/// corresponding envelope.
|
||||
#[arg(long, short)]
|
||||
pub preview: bool,
|
||||
|
||||
/// Read the raw version of the given message.
|
||||
///
|
||||
/// The raw message represents the headers and the body as it is
|
||||
@@ -79,7 +86,11 @@ impl MessageReadCommand {
|
||||
let backend = Backend::new(toml_account_config, account_config.clone(), false).await?;
|
||||
|
||||
let ids = &self.envelopes.ids;
|
||||
let emails = backend.get_messages(&folder, &ids).await?;
|
||||
let emails = if self.preview {
|
||||
backend.peek_messages(&folder, &ids).await
|
||||
} else {
|
||||
backend.get_messages(&folder, &ids).await
|
||||
}?;
|
||||
|
||||
let mut glue = "";
|
||||
let mut bodies = String::default();
|
||||
|
||||
+3
-2
@@ -6,7 +6,7 @@ use email::{
|
||||
};
|
||||
use log::debug;
|
||||
use mml::MmlCompilerBuilder;
|
||||
use process::Cmd;
|
||||
use process::SingleCmd;
|
||||
use std::{env, fs};
|
||||
|
||||
use crate::{
|
||||
@@ -23,7 +23,8 @@ pub async fn open_with_tpl(tpl: String) -> Result<String> {
|
||||
|
||||
debug!("open editor");
|
||||
let editor = env::var("EDITOR").context("cannot get editor from env var")?;
|
||||
Cmd::from(format!("{editor} {}", &path.to_string_lossy()))
|
||||
SingleCmd::from(format!("{editor} {}", &path.to_string_lossy()))
|
||||
.with_output_piped(false)
|
||||
.run()
|
||||
.await
|
||||
.context("cannot launch editor")?;
|
||||
|
||||
Reference in New Issue
Block a user