From 4d288b9d51c86da98d0c17513f7da2ff5213414e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DOUIN?= Date: Mon, 22 Jan 2024 10:39:06 +0100 Subject: [PATCH] fix missing notmuch backend features, improve docs --- CHANGELOG.md | 1 + CONTRIBUTING.md | 44 ++++++++-------------------- README.md | 8 +++-- src/email/message/command/copy.rs | 8 +++++ src/email/message/command/delete.rs | 10 +++++++ src/email/message/command/forward.rs | 8 +++++ src/email/message/command/mailto.rs | 8 +++++ src/email/message/command/move_.rs | 8 +++++ src/email/message/command/read.rs | 10 +++++++ src/email/message/command/reply.rs | 8 +++++ src/email/message/command/save.rs | 8 +++++ src/email/message/command/send.rs | 8 +++++ src/email/message/command/write.rs | 8 +++++ 13 files changed, 103 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdaf5f5..bbaf337 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `attachment` including `attachment-download` and the `attachment` subcommand - `template` including `template-write`, `template-reply`, `template-forward`, `template-save`, `template-send` and the `template` subcommand - Added wizard capability to autodetect IMAP and SMTP configurations, based on the [Thunderbird Autoconfiguration](https://wiki.mozilla.org/Thunderbird:Autoconfiguration) standard. +- Added back Notmuch backend features. ### Changed diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 79187ac..4014cc1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,49 +1,31 @@ -# Himalaya contributing guide +# Contributing guide -Thank you for investing your time in contributing to Himalaya! +Thank you for investing your time in contributing to Himalaya CLI! ## Development -The development environment is managed by -[Nix](https://nixos.org/download.html). Running `nix-shell` will spawn -a shell with everything you need to get started with the tool: -`cargo`, `cargo-watch`, `rust-bin`, `rust-analyzer`… +The development environment is managed by [Nix](https://nixos.org/download.html). Running `nix-shell` will spawn a shell with everything you need to get started with the lib: `cargo`, `cargo-watch`, `rust-bin`, `rust-analyzer`, `notmuch`… ```sh -# starts a nix shell (the first launch may take a while) +# Start a Nix shell $ nix-shell -# builds the CLI +# then build the CLI $ cargo build -# runs the CLI -$ cargo run -- list +# run the CLI +$ cargo run --feature pgp-gpg -- envelope list ``` ## Contributing -If you find a **bug**, please send an email at -[~soywod/pimalaya@todo.sr.ht](mailto:~soywod/pimalaya@todo.sr.ht). +Himalaya CLI supports open-source, hence the choice of using [sourcehut](https://sourcehut.org/) for managing the project. The only reason why the source code is hosted on GitHub is to build releases for all major platforms (using GitHub Actions). Don't worry, contributing on sourcehut is not a big deal: you just need to send emails! You don't need to create any account. Here a small comparison guide with GitHub: -If you have a **question**, please send an email at -[~soywod/pimalaya@lists.sr.ht](mailto:~soywod/pimalaya@lists.sr.ht). +The equivalent of **GitHub Discussions** are: -If you want to **propose a feature** or **fix a bug**, please send a -patch at -[~soywod/pimalaya@lists.sr.ht](mailto:~soywod/pimalaya@lists.sr.ht) -using [git send-email](https://git-scm.com/docs/git-send-email) (see -[this guide](https://git-send-email.io/) on how to configure it). +- The [Matrix](https://matrix.org/) chat room [#pimalaya.himalaya](https://matrix.to/#/#pimalaya.himalaya:matrix.org) +- The sourcehut mailing list. You can consult existing messages [here](https://lists.sr.ht/~soywod/pimalaya). You can "open a new discussion" by sending an email at [~soywod/pimalaya@lists.sr.ht](mailto:~soywod/pimalaya@lists.sr.ht). You can also [subscribe](mailto:~soywod/pimalaya+subscribe@lists.sr.ht) and [unsubscribe](mailto:~soywod/pimalaya+unsubscribe@lists.sr.ht) to the mailing list, so you can receive a copy of all discussions. -If you want to **subscribe** to the mailing list, please send an email -at -[~soywod/pimalaya+subscribe@lists.sr.ht](mailto:~soywod/pimalaya+subscribe@lists.sr.ht). +The equivalent of **GitHub Issues** is the sourcehut bug tracker. You can consult existing bugs [here](https://todo.sr.ht/~soywod/pimalaya), and you can "open a new issue" by sending an email at [~soywod/pimalaya@todo.sr.ht](mailto:~soywod/pimalaya@todo.sr.ht). -If you want to **unsubscribe** to the mailing list, please send an -email at -[~soywod/pimalaya+unsubscribe@lists.sr.ht](mailto:~soywod/pimalaya+unsubscribe@lists.sr.ht). - -If you want to **discuss** about the project, feel free to join the -[Matrix](https://matrix.org/) workspace -[#pimalaya.himalaya](https://matrix.to/#/#pimalaya.himalaya:matrix.org) -or contact me directly -[@soywod](https://matrix.to/#/@soywod:matrix.org). +The equivalent of **GitHub Pull requests** is the sourcehut mailing list. You can "open a new pull request" by sending an email containing a git patch at [~soywod/pimalaya@todo.sr.ht](mailto:~soywod/pimalaya@todo.sr.ht). The simplest way to send a patch is to use [git send-email](https://git-scm.com/docs/git-send-email), follow [this guide](https://git-send-email.io/) to configure git properly. diff --git a/README.md b/README.md index a7c52b1..0f9a81b 100644 --- a/README.md +++ b/README.md @@ -71,15 +71,17 @@ Please read the [documentation](https://pimalaya.org/himalaya/cli/latest/configu ## Contributing -A **bug tracker** is available at . +Pleas read the [contributing guide](https://github.com/soywod/himalaya/blob/master/CONTRIBUTING.md) for more detailed information. -A **mailing list** is available at . +A **bug tracker** is available on [sourcehut](https://todo.sr.ht/~soywod/pimalaya) [[send an email](mailto:~soywod/pimalaya@todo.sr.ht)]. + +A **mailing list** is available on [sourcehut](https://lists.sr.ht/~soywod/pimalaya) [[send an email](mailto:~soywod/pimalaya@lists.sr.ht)|[subscribe](mailto:~soywod/pimalaya+subscribe@lists.sr.ht)|[unsubscribe](mailto:~soywod/pimalaya+unsubscribe@lists.sr.ht)]. If you want to **report a bug**, please send an email at [~soywod/pimalaya@todo.sr.ht](mailto:~soywod/pimalaya@todo.sr.ht). If you want to **propose a feature** or **fix a bug**, please send a patch at [~soywod/pimalaya@lists.sr.ht](mailto:~soywod/pimalaya@lists.sr.ht). The simplest way to send a patch is to use [git send-email](https://git-scm.com/docs/git-send-email), follow [this guide](https://git-send-email.io/) to configure git properly. -If you just want to **discuss** about the project, feel free to join the [Matrix](https://matrix.org/) workspace [#pimalaya.himalaya](https://matrix.to/#/#pimalaya.himalaya:matrix.org) or contact me directly [@soywod](https://matrix.to/#/@soywod:matrix.org). You can also use the mailing list [[send an email](mailto:~soywod/pimalaya@lists.sr.ht)|[subscribe](mailto:~soywod/pimalaya+subscribe@lists.sr.ht)|[unsubscribe](mailto:~soywod/pimalaya+unsubscribe@lists.sr.ht)]. +If you just want to **discuss** about the project, feel free to join the [Matrix](https://matrix.org/) workspace [#pimalaya.himalaya](https://matrix.to/#/#pimalaya.himalaya:matrix.org) or contact me directly [@soywod](https://matrix.to/#/@soywod:matrix.org). You can also use the mailing list. ## Sponsoring diff --git a/src/email/message/command/copy.rs b/src/email/message/command/copy.rs index c6017e6..9230365 100644 --- a/src/email/message/command/copy.rs +++ b/src/email/message/command/copy.rs @@ -4,6 +4,8 @@ use clap::Parser; use email::message::copy::imap::CopyImapMessages; #[cfg(feature = "maildir")] use email::message::copy::maildir::CopyMaildirMessages; +#[cfg(feature = "notmuch")] +use email::message::copy::notmuch::CopyNotmuchMessages; use log::info; #[cfg(feature = "account-sync")] @@ -79,6 +81,12 @@ impl MessageCopyCommand { .map(CopyMaildirMessages::new_boxed) }); } + #[cfg(feature = "notmuch")] + Some(BackendKind::Notmuch) => { + builder.set_copy_messages(|ctx| { + ctx.notmuch.as_ref().map(CopyNotmuchMessages::new_boxed) + }); + } _ => (), }, ) diff --git a/src/email/message/command/delete.rs b/src/email/message/command/delete.rs index 8ba7429..57aa05b 100644 --- a/src/email/message/command/delete.rs +++ b/src/email/message/command/delete.rs @@ -4,6 +4,8 @@ use clap::Parser; use email::{flag::add::imap::AddImapFlags, message::move_::imap::MoveImapMessages}; #[cfg(feature = "maildir")] use email::{flag::add::maildir::AddMaildirFlags, message::move_::maildir::MoveMaildirMessages}; +#[cfg(feature = "notmuch")] +use email::{flag::add::notmuch::AddNotmuchFlags, message::move_::notmuch::MoveNotmuchMessages}; use log::info; #[cfg(feature = "account-sync")] @@ -88,6 +90,14 @@ impl MessageDeleteCommand { .map(AddMaildirFlags::new_boxed) }); } + #[cfg(feature = "notmuch")] + Some(BackendKind::Notmuch) => { + builder.set_move_messages(|ctx| { + ctx.notmuch.as_ref().map(MoveNotmuchMessages::new_boxed) + }); + builder + .set_add_flags(|ctx| ctx.notmuch.as_ref().map(AddNotmuchFlags::new_boxed)); + } _ => (), }, ) diff --git a/src/email/message/command/forward.rs b/src/email/message/command/forward.rs index 3d9961f..633b8e4 100644 --- a/src/email/message/command/forward.rs +++ b/src/email/message/command/forward.rs @@ -4,6 +4,8 @@ use clap::Parser; use email::message::add::imap::AddImapMessage; #[cfg(feature = "maildir")] use email::message::add::maildir::AddMaildirMessage; +#[cfg(feature = "notmuch")] +use email::message::add::notmuch::AddNotmuchMessage; #[cfg(feature = "sendmail")] use email::message::send::sendmail::SendSendmailMessage; #[cfg(feature = "smtp")] @@ -93,6 +95,12 @@ impl MessageForwardCommand { .map(AddMaildirMessage::new_boxed) }); } + #[cfg(feature = "notmuch")] + Some(BackendKind::Notmuch) => { + builder.set_add_message(|ctx| { + ctx.notmuch.as_ref().map(AddNotmuchMessage::new_boxed) + }); + } _ => (), }; diff --git a/src/email/message/command/mailto.rs b/src/email/message/command/mailto.rs index 8b5af27..15b7e28 100644 --- a/src/email/message/command/mailto.rs +++ b/src/email/message/command/mailto.rs @@ -4,6 +4,8 @@ use clap::Parser; use email::message::add::imap::AddImapMessage; #[cfg(feature = "maildir")] use email::message::add::maildir::AddMaildirMessage; +#[cfg(feature = "notmuch")] +use email::message::add::notmuch::AddNotmuchMessage; #[cfg(feature = "sendmail")] use email::message::send::sendmail::SendSendmailMessage; #[cfg(feature = "smtp")] @@ -90,6 +92,12 @@ impl MessageMailtoCommand { .map(AddMaildirMessage::new_boxed) }); } + #[cfg(feature = "notmuch")] + Some(BackendKind::Notmuch) => { + builder.set_add_message(|ctx| { + ctx.notmuch.as_ref().map(AddNotmuchMessage::new_boxed) + }); + } _ => (), }; diff --git a/src/email/message/command/move_.rs b/src/email/message/command/move_.rs index d0eac06..bc69243 100644 --- a/src/email/message/command/move_.rs +++ b/src/email/message/command/move_.rs @@ -4,6 +4,8 @@ use clap::Parser; use email::message::move_::imap::MoveImapMessages; #[cfg(feature = "maildir")] use email::message::move_::maildir::MoveMaildirMessages; +#[cfg(feature = "notmuch")] +use email::message::move_::notmuch::MoveNotmuchMessages; use log::info; #[cfg(feature = "account-sync")] @@ -79,6 +81,12 @@ impl MessageMoveCommand { .map(MoveMaildirMessages::new_boxed) }); } + #[cfg(feature = "notmuch")] + Some(BackendKind::Notmuch) => { + builder.set_move_messages(|ctx| { + ctx.notmuch.as_ref().map(MoveNotmuchMessages::new_boxed) + }); + } _ => (), }, ) diff --git a/src/email/message/command/read.rs b/src/email/message/command/read.rs index d326437..6fb8388 100644 --- a/src/email/message/command/read.rs +++ b/src/email/message/command/read.rs @@ -4,6 +4,8 @@ use clap::Parser; use email::message::{get::imap::GetImapMessages, peek::imap::PeekImapMessages}; #[cfg(feature = "maildir")] use email::{flag::add::maildir::AddMaildirFlags, message::peek::maildir::PeekMaildirMessages}; +#[cfg(feature = "notmuch")] +use email::{flag::add::notmuch::AddNotmuchFlags, message::peek::notmuch::PeekNotmuchMessages}; use log::info; use mml::message::FilterParts; @@ -133,6 +135,14 @@ impl MessageReadCommand { .map(AddMaildirFlags::new_boxed) }); } + #[cfg(feature = "notmuch")] + Some(BackendKind::Notmuch) => { + builder.set_peek_messages(|ctx| { + ctx.notmuch.as_ref().map(PeekNotmuchMessages::new_boxed) + }); + builder + .set_add_flags(|ctx| ctx.notmuch.as_ref().map(AddNotmuchFlags::new_boxed)); + } _ => (), }, ) diff --git a/src/email/message/command/reply.rs b/src/email/message/command/reply.rs index 7611e4d..5d4fce3 100644 --- a/src/email/message/command/reply.rs +++ b/src/email/message/command/reply.rs @@ -4,6 +4,8 @@ use clap::Parser; use email::message::add::imap::AddImapMessage; #[cfg(feature = "maildir")] use email::message::add::maildir::AddMaildirMessage; +#[cfg(feature = "notmuch")] +use email::message::add::notmuch::AddNotmuchMessage; #[cfg(feature = "sendmail")] use email::message::send::sendmail::SendSendmailMessage; #[cfg(feature = "smtp")] @@ -95,6 +97,12 @@ impl MessageReplyCommand { .map(AddMaildirMessage::new_boxed) }); } + #[cfg(feature = "notmuch")] + Some(BackendKind::Notmuch) => { + builder.set_add_message(|ctx| { + ctx.notmuch.as_ref().map(AddNotmuchMessage::new_boxed) + }); + } _ => (), }; diff --git a/src/email/message/command/save.rs b/src/email/message/command/save.rs index c8a9f4a..95592b4 100644 --- a/src/email/message/command/save.rs +++ b/src/email/message/command/save.rs @@ -4,6 +4,8 @@ use clap::Parser; use email::message::add::imap::AddImapMessage; #[cfg(feature = "maildir")] use email::message::add::maildir::AddMaildirMessage; +#[cfg(feature = "notmuch")] +use email::message::add::notmuch::AddNotmuchMessage; use log::info; use std::io::{self, BufRead, IsTerminal}; @@ -75,6 +77,12 @@ impl MessageSaveCommand { .map(AddMaildirMessage::new_boxed) }); } + #[cfg(feature = "notmuch")] + Some(BackendKind::Notmuch) => { + builder.set_add_message(|ctx| { + ctx.notmuch.as_ref().map(AddNotmuchMessage::new_boxed) + }); + } _ => (), }, ) diff --git a/src/email/message/command/send.rs b/src/email/message/command/send.rs index a7945a8..4535fa3 100644 --- a/src/email/message/command/send.rs +++ b/src/email/message/command/send.rs @@ -4,6 +4,8 @@ use clap::Parser; use email::message::add::imap::AddImapMessage; #[cfg(feature = "maildir")] use email::message::add::maildir::AddMaildirMessage; +#[cfg(feature = "notmuch")] +use email::message::add::notmuch::AddNotmuchMessage; #[cfg(feature = "sendmail")] use email::message::send::sendmail::SendSendmailMessage; #[cfg(feature = "smtp")] @@ -84,6 +86,12 @@ impl MessageSendCommand { .map(AddMaildirMessage::new_boxed) }); } + #[cfg(feature = "notmuch")] + Some(BackendKind::Notmuch) => { + builder.set_add_message(|ctx| { + ctx.notmuch.as_ref().map(AddNotmuchMessage::new_boxed) + }); + } _ => (), }; match send_message_kind { diff --git a/src/email/message/command/write.rs b/src/email/message/command/write.rs index 241a5e2..ecf2639 100644 --- a/src/email/message/command/write.rs +++ b/src/email/message/command/write.rs @@ -4,6 +4,8 @@ use clap::Parser; use email::message::add::imap::AddImapMessage; #[cfg(feature = "maildir")] use email::message::add::maildir::AddMaildirMessage; +#[cfg(feature = "notmuch")] +use email::message::add::notmuch::AddNotmuchMessage; #[cfg(feature = "sendmail")] use email::message::send::sendmail::SendSendmailMessage; #[cfg(feature = "smtp")] @@ -84,6 +86,12 @@ impl MessageWriteCommand { .map(AddMaildirMessage::new_boxed) }); } + #[cfg(feature = "notmuch")] + Some(BackendKind::Notmuch) => { + builder.set_add_message(|ctx| { + ctx.notmuch.as_ref().map(AddNotmuchMessage::new_boxed) + }); + } _ => (), };