From 1f6cf0616602a32575e9c258153bc6bc2e2d3856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DOUIN?= Date: Tue, 26 May 2026 19:40:35 +0200 Subject: [PATCH] chore: clean --- Cargo.lock | 20 ++--- Cargo.toml | 14 ++++ MIGRATION.md | 2 +- README.md | 144 +++++++++++++---------------------- config.sample.toml | 10 ++- deny.toml | 4 +- src/maildir/envelope/list.rs | 3 +- src/maildir/flag/add.rs | 8 +- src/maildir/flag/arg.rs | 16 ++-- src/maildir/flag/list.rs | 16 ++-- src/maildir/flag/remove.rs | 8 +- src/maildir/flag/set.rs | 8 +- src/maildir/message/save.rs | 4 +- src/shared/flags/arg.rs | 12 +-- 14 files changed, 126 insertions(+), 143 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 61df1fd7..6050198a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1062,7 +1062,7 @@ dependencies = [ [[package]] name = "io-email" version = "0.0.1" -source = "git+https://github.com/pimalaya/io-email#6cfb80f0b694bff3334678893724e1a763c20cb8" +source = "git+https://github.com/pimalaya/io-email#db314793398f252023d0a2b2ac3bc2145d93d11a" dependencies = [ "chrono", "chumsky", @@ -1101,7 +1101,7 @@ dependencies = [ [[package]] name = "io-imap" version = "0.0.1" -source = "git+https://github.com/pimalaya/io-imap#0a6a3ef4761b12b29cd5b9178b0cb7889d84ccbc" +source = "git+https://github.com/pimalaya/io-imap#b6871a87f5b491003dbcc61bcdde4dd5d0b17828" dependencies = [ "anyhow", "base64", @@ -1141,7 +1141,7 @@ dependencies = [ [[package]] name = "io-maildir" version = "0.0.1" -source = "git+https://github.com/pimalaya/io-maildir#ac75cf8359ce828e5702f1c912e52bb9cfb66c6d" +source = "git+https://github.com/pimalaya/io-maildir#ca5075379f7ab5879626c1b98df2471cf8c25a19" dependencies = [ "gethostname", "log", @@ -1199,9 +1199,9 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "jiff" -version = "0.2.24" +version = "0.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00b5dbd620d61dfdcb6007c9c1f6054ebd75319f163d886a9055cec1155073d" +checksum = "392c70591e8749fe235ddaf513e6f58b26bce3dcc16524cecc8936f75afa161e" dependencies = [ "jiff-static", "log", @@ -1212,9 +1212,9 @@ dependencies = [ [[package]] name = "jiff-static" -version = "0.2.24" +version = "0.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e000de030ff8022ea1da3f466fbb0f3a809f5e51ed31f6dd931c35181ad8e6d7" +checksum = "47b605b0c050d845fc355bb11eb3f9a8deddc218ea60c76e61aa1f2adfb2c96a" dependencies = [ "proc-macro2", "quote", @@ -1372,9 +1372,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.29" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" +checksum = "616ec5685824bcc94416c6d4a7a446eea774a31efd7062c8480ba6fd06d7a6e5" [[package]] name = "mail-builder" @@ -1619,7 +1619,7 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pimalaya-cli" version = "0.0.1" -source = "git+https://github.com/pimalaya/cli#c3ead3ae2dd74d98e5a695bc476d74399d7a6c0b" +source = "git+https://github.com/pimalaya/cli#7e7287d081f5907874b3159bf20b55f259636ff7" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index e62d115c..f57b9479 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,6 +82,20 @@ serde = "1" serde_json = "1" tempfile = "3" +# [patch.crates-io] +# domain = { git = "https://github.com/soywod/domain", branch = "new-srv" } +# io-discovery.path = "../io-discovery" +# io-email.path = "../io-email" +# io-http.path = "../io-http" +# io-imap.path = "../io-imap" +# io-jmap.path = "../io-jmap" +# io-m2dir.path = "../io-m2dir" +# io-maildir.path = "../io-maildir" +# io-smtp.path = "../io-smtp" +# pimalaya-cli.path = "../cli" +# pimalaya-config.path = "../config" +# pimalaya-stream.path = "../stream" + [patch.crates-io] domain = { git = "https://github.com/soywod/domain", branch = "new-srv" } io-discovery.git = "https://github.com/pimalaya/io-discovery" diff --git a/MIGRATION.md b/MIGRATION.md index c51395a8..256cb70b 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -96,7 +96,7 @@ The full configuration schema is documented in [config.sample.toml](./config.sam - Removed `display-name`, `signature`, `signature-delim`: composition left the CLI. - Only `downloads-dir` remains for the `attachments download` command. -- Composition / reading hooks live under `[message.composer.]` and `[message.reader.]`; each entry sets a `command` and optionally `default = true`. +- Composition / reading hooks live under `[message.composer.]` and `[message.reader.]`, each optionally flagged `default = true`. A composer entry sets one shell command per operation (`compose`, `reply`, `forward`); a reader entry sets a single `command`. - The `message`, `template` and `pgp` top-level entries are removed. #### Table customization diff --git a/README.md b/README.md index 63ae4c3e..9ef2dd53 100644 --- a/README.md +++ b/README.md @@ -3,17 +3,11 @@

đź“« Himalaya

CLI to manage emails

- Release - Repology Matrix Mastodon

-``` -himalaya envelopes list --account posteo -m Archives.FOSS --page 2 -``` - ![screenshot](./screenshot.jpeg) > [!IMPORTANT] @@ -47,27 +41,30 @@ himalaya envelopes list --account posteo -m Archives.FOSS --page 2 - **Shared API** that maps `mailboxes`, `envelopes`, `flags`, `messages` and `attachments` to the active backend - **Protocol-specific APIs** exposing each backend's full surface (`himalaya imap/smtp/maildir/jmap…`) -- **IMAP** support [rfc9051](https://www.iana.org/go/rfc9051) (requires `imap` feature) -- **JMAP** support [rfc8620](https://www.iana.org/go/rfc8620), [rfc8621](https://www.iana.org/go/rfc8621) (requires `jmap` feature) -- **Maildir** support (requires `maildir` feature) -- **SMTP** backend [rfc5321](https://www.iana.org/go/rfc5321) (requires `smtp` feature) +- Remote backend support: **IMAP**, **SMTP**, **JMAP** +- Local (filesystem) backends support: **Maildir** [specs](https://cr.yp.to/proto/maildir.html), **m2dir** [specs](https://man.sr.ht/~bitfehler/m2dir/) +- **Simple auth** support for IMAP/SMTP: anonymous, login, plain, oauthbearer, xoauth2, scram-sha-256 +- **HTTP auth** support for JMAP: basic, bearer - **TLS** support: - - [native-tls](https://crates.io/crates/native-tls) (requires `native-tls` feature) - - [rustls](https://crates.io/crates/rustls): - - AWS-LC crypto provider (requires `rustls-aws` feature) - - Ring crypto provider (requires `rustls-ring` feature) -- **SASL** support: anonymous, login, plain, oauthbearer, xoauth2, scram-sha-256 -- **Provider discovery** wizard powered by [io-discovery](https://github.com/pimalaya/io-discovery): Thunderbird Autoconfiguration, PACC and RFC 6186 SRV lookups -- **TOML** configuration with multi-account support + - [Rustls](https://crates.io/crates/rustls) with ring crypto + - [Rustls](https://crates.io/crates/rustls) with aws crypto (requires `rustls-aws` feature) + - [Native TLS](https://crates.io/crates/native-tls) (requires `native-tls` feature) +- **Discovery** support: + - PACC [specs](https://datatracker.ietf.org/doc/html/draft-ietf-mailmaint-pacc) + - Autoconfiguration (Thunderbird) [specs](https://wiki.mozilla.org/Thunderbird:Autoconfiguration) + - SRV DNS lookups [rfc6186](https://datatracker.ietf.org/doc/html/rfc6186) +- **TOML configuration** with multi-account support +- **Shared configuration file** with `himalaya-tui`: same `[accounts.]` blocks load on both binaries (see [Configuration](#configuration)) - **JSON** output via `--json` -*Himalaya CLI is written in [Rust](https://www.rust-lang.org/), and relies on [cargo features](https://doc.rust-lang.org/cargo/reference/features.html) to enable or disable functionalities. Default features can be found in the `features` section of the [`Cargo.toml`](./Cargo.toml#L18), or on [docs.rs](https://docs.rs/crate/himalaya/latest/features).* +> [!TIP] +> Himalaya is written in [Rust](https://www.rust-lang.org/) and uses [cargo features](https://doc.rust-lang.org/cargo/reference/features.html) to gate backend support. The default feature set is declared in [Cargo.toml](./Cargo.toml). ## Installation ### Pre-built binary -Himalaya CLI can be installed with the `install.sh` installer: +Himalaya can be installed with the `install.sh` installer: *As root:* @@ -83,39 +80,34 @@ curl -sSL https://raw.githubusercontent.com/pimalaya/himalaya/master/install.sh These commands install the latest binary from the GitHub [releases](https://github.com/pimalaya/himalaya/releases) section. -If you want a more up-to-date version than the latest release, check out the [releases](https://github.com/pimalaya/himalaya/actions/workflows/releases.yml) GitHub workflow and look for the *Artifacts* section. You will find a pre-built binary matching your OS. These pre-built binaries are built from the `master` branch. +For a more up-to-date version than the latest release, check out the [releases](https://github.com/pimalaya/himalaya/actions/workflows/releases.yml) GitHub workflow and look for the *Artifacts* section. These pre-built binaries are built from the `master` branch. -*Such binaries are built with the default cargo features. If you need more features, please use another installation method.* +> [!NOTE] +> Such binaries are built with the default cargo features. If you need specific features, please use another installation method. ### Cargo -Himalaya CLI can be installed with [cargo](https://doc.rust-lang.org/cargo/): - -``` -cargo install himalaya --locked -``` - -With only IMAP support: - -``` -cargo install himalaya --locked --no-default-features --features imap -``` - -You can also use the git repository for a more up-to-date (but less stable) version: - ``` cargo install --locked --git https://github.com/pimalaya/himalaya.git ``` +With only IMAP+SMTP support: + +``` +cargo install --locked --git https://github.com/pimalaya/himalaya.git \ + --no-default-features \ + --features imap,smtp,rustls-ring +``` + ### Arch Linux -Himalaya CLI can be installed on [Arch Linux](https://archlinux.org/) with either the community repository: +From the community repository: ``` pacman -S himalaya ``` -or the [user repository](https://aur.archlinux.org/): +Or the [user repository](https://aur.archlinux.org/): ``` git clone https://aur.archlinux.org/himalaya-git.git @@ -123,7 +115,7 @@ cd himalaya-git makepkg -isc ``` -If you use [yay](https://github.com/Jguer/yay), it is even simplier: +Or with [yay](https://github.com/Jguer/yay): ``` yay -S himalaya-git @@ -131,25 +123,22 @@ yay -S himalaya-git ### Homebrew -Himalaya CLI can be installed with [Homebrew](https://brew.sh/): - ``` brew install himalaya ``` -Note: cargo features are not compatible with brew. If you need a different feature set, please use another installation method. +> [!NOTE] +> Cargo features are not compatible with brew. If you need a different feature set, please use another installation method. ### Scoop -Himalaya CLI can be installed with [Scoop](https://scoop.sh/): - ``` scoop install himalaya ``` ### Fedora Linux/CentOS/RHEL -Himalaya CLI can be installed on [Fedora Linux](https://fedoraproject.org/)/CentOS/RHEL via the [COPR](https://copr.fedorainfracloud.org/coprs/atim/himalaya/) repo: +From the [COPR](https://copr.fedorainfracloud.org/coprs/atim/himalaya/) repo: ``` dnf copr enable atim/himalaya @@ -158,37 +147,13 @@ dnf install himalaya ### Nix -Himalaya CLI can be installed with [Nix](https://serokell.io/blog/what-is-nix): - -``` -nix-env -i himalaya -``` - -You can also use the git repository for a more up-to-date (but less stable) version: - -``` -nix-env -if https://github.com/pimalaya/himalaya/archive/master.tar.gz -``` - -*Or, from within the source tree checkout:* - -``` -nix-env -if . -``` - If you have the [Flakes](https://nixos.wiki/wiki/Flakes) feature enabled: ``` nix profile install github:pimalaya/himalaya ``` -*Or, from within the source tree checkout:* - -``` -nix profile install -``` - -*You can also run Himalaya directly without installing it:* +Or run without installing: ``` nix run github:pimalaya/himalaya @@ -199,28 +164,25 @@ nix run github:pimalaya/himalaya ``` git clone https://github.com/pimalaya/himalaya cd himalaya -nix develop --command cargo build --release +nix run ``` -*Binaries are available under the `target/release` folder.* - ## Configuration -Just run `himalaya`. When no configuration file is found, the wizard prompts for an account name and email address, runs [provider discovery](https://github.com/pimalaya/io-discovery) (PACC → Thunderbird Autoconfiguration → RFC 6186 SRV), fills the IMAP/SMTP (or JMAP) prompts with the discovered defaults, and writes the result to disk. +Run `himalaya`. With no configuration file on disk the wizard prompts for an account name and an email address, runs provider discovery (PACC, then Thunderbird Autoconfiguration, then RFC 6186 SRV), fills the IMAP/SMTP (or JMAP) prompts with the discovered defaults, then writes the result to disk. + +A persistent configuration is loaded from the first valid path among: + +- `$XDG_CONFIG_HOME/himalaya/config.toml` +- `$HOME/.config/himalaya/config.toml` +- `$HOME/.himalayarc` + +These are the same paths the [himalaya-tui](https://github.com/pimalaya/himalaya-tui) TUI looks at: one TOML file backs both binaries. CLI-only fields and TUI-only sections coexist without errors. See [config.sample.toml](./config.sample.toml) for a documented template. + +Override the path with `-c ` or `HIMALAYA_CONFIG=`; multiple paths can be passed at once, separated by `:`. The first one is the base and the rest are deep-merged on top. Accounts can be (re)configured later with `himalaya account configure `. The wizard skips discovery in this mode: it reuses the existing values as prompt defaults. -You can also write the configuration by hand: - -- Copy the documented [./config.sample.toml](./config.sample.toml) -- Paste it into one of: - - `$XDG_CONFIG_HOME/himalaya/config.toml` - - `$HOME/.config/himalaya/config.toml` - - `$HOME/.himalayarc` -- Comment or uncomment the options you want - -…or pass `-c ` / set `HIMALAYA_CONFIG=`. Multiple paths can be passed at once, separated by `:`; the first is the base and the rest are deep-merged on top. - ## Usage ### Shared API @@ -272,11 +234,13 @@ himalaya messages compose --from me@example.org --to you@example.org \ --subject "Hello" --body "Hi!" --send ``` -For richer composition (multipart MIME, MML directives, signing/encryption, editor-driven workflows…), wire a user-defined composer in `[message.composer.*]` and invoke it with the `-with` variants. For example, with [`mml`](https://github.com/pimalaya/mml): +For richer composition (multipart MIME, MML directives, signing/encryption, editor-driven workflows…), wire a user-defined composer in `[message.composer.*]` and invoke it with the `-with` variants. Each entry declares one shell command per operation (`compose` for blank drafts and `mailto`, `reply` for replies, `forward` for forwards); the source message is piped on stdin for `reply` / `forward`. For example, with [mml](https://github.com/pimalaya/mml): ```toml [message.composer.mml] -command = "mml compose" +compose = "mml compose" +reply = "mml reply" +forward = "mml forward" default = true ``` @@ -287,7 +251,7 @@ himalaya messages forward-with -m INBOX 42 --send himalaya messages mailto 'mailto:bob@example.org?subject=Hi&body=Hello' ``` -`messages mailto ` parses an RFC 6068 `mailto:` URI (recipient list in the path, `to` / `cc` / `bcc` / `subject` / `body` query parameters), builds a draft RFC 5322 skeleton with those headers pre-filled, then pipes it on stdin to the named (or default) composer for editing. The composer's output is routed through `--save` / `--send` like the other `-with` variants. Useful as a desktop `mailto:` handler. +`messages mailto ` parses an RFC 6068 `mailto:` URI (recipient list in the path, `to` / `cc` / `bcc` / `subject` / `body` query parameters), builds a draft RFC 5322 skeleton with those headers pre-filled, then pipes it on stdin to the named (or default) composer's `compose` command. The composer's output is routed through `--save` / `--send` like the other `-with` variants. Useful as a desktop `mailto:` handler. ### Reading messages @@ -309,7 +273,7 @@ Each invocation opens a fresh TCP+TLS+SASL session by default. To amortize the h ## Interfaces -These interfaces are built at the top of Himalaya CLI to improve the User Experience: +Himalaya CLI is one of several front-ends to the Pimalaya libraries: - [pimalaya/himalaya-tui](https://github.com/pimalaya/himalaya-tui): official TUI (in active development) - [pimalaya/himalaya-vim](https://github.com/pimalaya/himalaya-vim): Vim plugin @@ -327,7 +291,7 @@ These interfaces are built at the top of Himalaya CLI to improve the User Experi Himalaya is a Command-Line Interface (CLI). There is no event loop: you interact with your emails using shell commands, in a stateless way. - A dedicated TUI ([himalaya-tui](https://github.com/pimalaya/himalaya-tui)) is in active development on top of the same Pimalaya libraries. + A dedicated TUI ([himalaya-tui](https://github.com/pimalaya/himalaya-tui)) is in active development on top of the same Pimalaya libraries, and is definitely closer to aerc, mutt and alpine.
@@ -363,7 +327,7 @@ These interfaces are built at the top of Himalaya CLI to improve the User Experi
- How to debug Himalaya CLI? + How to debug Himalaya? Use `--log-level ` (alias `--log`) where `` is one of `off`, `error`, `warn`, `info`, `debug`, `trace`: diff --git a/config.sample.toml b/config.sample.toml index c1d0c3ed..44385708 100644 --- a/config.sample.toml +++ b/config.sample.toml @@ -127,15 +127,19 @@ # Composers produce a MIME draft on stdout. They are invoked by the # `messages compose-with` / `reply-with` / `forward-with` subcommands. -# Stdin carries the source MIME bytes (empty for new messages); stderr is -# inherited so the composer can prompt the user. +# Each entry declares one shell command per operation: `compose` (for blank +# drafts and `mailto`), `reply`, and `forward`. Stdin carries the source MIME +# bytes for `reply` / `forward` and is empty for `compose`; stderr is inherited +# so the composer can prompt the user. # # Pick one with `compose-with `, or let himalaya use the entry flagged # `default = true` when no name is passed. # # Example using https://github.com/pimalaya/mml: #[message.composer.mml] -#command = "mml compose" +#compose = "mml compose" +#reply = "mml reply" +#forward = "mml forward" #default = true # Readers consume a MIME message on stdin and emit human-readable bytes on diff --git a/deny.toml b/deny.toml index 538388ad..6aa4a9b3 100644 --- a/deny.toml +++ b/deny.toml @@ -11,7 +11,7 @@ allow-git = [ "https://github.com/pimalaya/io-maildir", "https://github.com/pimalaya/io-smtp", "https://github.com/pimalaya/stream", - "https://github.com/soywod/domain" + "https://github.com/soywod/domain", ] unknown-git = "deny" unknown-registry = "deny" @@ -28,5 +28,5 @@ allow = [ "MIT", "MPL-2.0", "Unicode-3.0", - "Zlib" + "Zlib", ] diff --git a/src/maildir/envelope/list.rs b/src/maildir/envelope/list.rs index 8a642737..79ffec49 100644 --- a/src/maildir/envelope/list.rs +++ b/src/maildir/envelope/list.rs @@ -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()); diff --git a/src/maildir/flag/add.rs b/src/maildir/flag/add.rs index 665e4b1c..b52fe578 100644 --- a/src/maildir/flag/add.rs +++ b/src/maildir/flag/add.rs @@ -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, } @@ -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")) } } diff --git a/src/maildir/flag/arg.rs b/src/maildir/flag/arg.rs index 5a2d3b80..dc151df1 100644 --- a/src/maildir/flag/arg.rs +++ b/src/maildir/flag/arg.rs @@ -16,7 +16,7 @@ // along with this program. If not, see . 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 for Flag { +impl From 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, } } } diff --git a/src/maildir/flag/list.rs b/src/maildir/flag/list.rs index 41fb59d2..8b046a37 100644 --- a/src/maildir/flag/list.rs +++ b/src/maildir/flag/list.rs @@ -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:?}"), diff --git a/src/maildir/flag/remove.rs b/src/maildir/flag/remove.rs index 5f0533de..4fce223f 100644 --- a/src/maildir/flag/remove.rs +++ b/src/maildir/flag/remove.rs @@ -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, } @@ -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")) } } diff --git a/src/maildir/flag/set.rs b/src/maildir/flag/set.rs index bc40598a..94125d1c 100644 --- a/src/maildir/flag/set.rs +++ b/src/maildir/flag/set.rs @@ -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, } @@ -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")) } } diff --git a/src/maildir/message/save.rs b/src/maildir/message/save.rs index 9bb46c47..bffc7cd7 100644 --- a/src/maildir/message/save.rs +++ b/src/maildir/message/save.rs @@ -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()); diff --git a/src/shared/flags/arg.rs b/src/shared/flags/arg.rs index 5bfe46d0..c1d094d1 100644 --- a/src/shared/flags/arg.rs +++ b/src/shared/flags/arg.rs @@ -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, } } }