diff --git a/Cargo.lock b/Cargo.lock index 099bdf7..2201059 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2445,8 +2445,6 @@ dependencies = [ [[package]] name = "keyring-lib" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dcc9433b6eaf33f2f6a8d3a53b598a5d0b8be224c41bd98d1ec936ef4d02d69" dependencies = [ "keyring", "log", @@ -3233,10 +3231,10 @@ dependencies = [ [[package]] name = "process-lib" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe824234b824573ff3a80ddf3a6b19e6ffba966798d071f280723ee02a7273ce" dependencies = [ + "anyhow", "log", + "once_cell", "thiserror", "tokio", ] @@ -3707,9 +3705,8 @@ dependencies = [ [[package]] name = "secret-lib" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d46e99ae858a1978ec3e6e887966514900229fc0df99935a2c61102854f9195e" dependencies = [ + "anyhow", "keyring-lib", "log", "process-lib", diff --git a/Cargo.toml b/Cargo.toml index 21a4b20..b0c6de5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -104,7 +104,8 @@ default-features = false path = "/home/soywod/sourcehut/pimalaya/email" [dependencies.keyring-lib] -version = "=0.1.0" +# version = "=0.1.0" +path = "/home/soywod/sourcehut/pimalaya/keyring" [dependencies.mail-builder] version = "0.3" @@ -114,7 +115,8 @@ version = "0.3" path = "/home/soywod/sourcehut/pimalaya/oauth" [dependencies.process-lib] -version = "=0.1.0" +# version = "=0.1.0" +path = "/home/soywod/sourcehut/pimalaya/process" [dependencies.mml-lib] # version = "=1.0.1" @@ -123,7 +125,8 @@ features = ["compiler", "interpreter"] path = "/home/soywod/sourcehut/pimalaya/mml" [dependencies.secret-lib] -version = "=0.1.0" +# version = "=0.1.0" +path = "/home/soywod/sourcehut/pimalaya/secret" [dependencies.serde] version = "1.0" diff --git a/src/email/message/command/read.rs b/src/email/message/command/read.rs index 8acb3c1..49cab78 100644 --- a/src/email/message/command/read.rs +++ b/src/email/message/command/read.rs @@ -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(); diff --git a/src/ui/editor.rs b/src/ui/editor.rs index 34eef3c..e7caeb7 100644 --- a/src/ui/editor.rs +++ b/src/ui/editor.rs @@ -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 { 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")?;