I've been using pm-cli heavily for automated email processing and have run into a few limitations with mail list that I'd like to propose fixing:
Server-side filtering: The --unread flag currently fetches N messages and filters client-side, so you often get back fewer results than the limit. Switching to IMAP SEARCH UNSEEN would return the right count. I'd also like to add --flagged (SEARCH FLAGGED). I use starred messages as a workflow signal and currently have to pull 200 messages and filter for flagged==true in a script.
Missing envelope fields: mail list only exposes the display name in from, which drops the actual email address when a display name is present. This makes it impossible to match on sender domain without an extra mail read call per message. I'd like to add from_address, to, message_id, and in_reply_to. All four are already in the IMAP ENVELOPE response, so there's zero additional fetch cost. in_reply_to is useful for reconstructing reply chains from list output without per-message reads.
Field selection: For consumers that only need a few fields per message, the full JSON envelope is wasteful. I'm proposing --fields (comma-separated list of fields to include in JSON output) and --compact (bare JSON array instead of the wrapper object). These only affect --json mode; text output is unchanged.
The implementation refactors ListMessages to accept a ListOptions struct instead of positional parameters, which makes it cleaner to extend. I can split this into smaller PRs if preferred.
Branch: feat/mail-list-enhancements
I've been using pm-cli heavily for automated email processing and have run into a few limitations with
mail listthat I'd like to propose fixing:Server-side filtering: The
--unreadflag currently fetches N messages and filters client-side, so you often get back fewer results than the limit. Switching to IMAPSEARCH UNSEENwould return the right count. I'd also like to add--flagged(SEARCH FLAGGED). I use starred messages as a workflow signal and currently have to pull 200 messages and filter forflagged==truein a script.Missing envelope fields:
mail listonly exposes the display name infrom, which drops the actual email address when a display name is present. This makes it impossible to match on sender domain without an extramail readcall per message. I'd like to addfrom_address,to,message_id, andin_reply_to. All four are already in the IMAP ENVELOPE response, so there's zero additional fetch cost.in_reply_tois useful for reconstructing reply chains from list output without per-message reads.Field selection: For consumers that only need a few fields per message, the full JSON envelope is wasteful. I'm proposing
--fields(comma-separated list of fields to include in JSON output) and--compact(bare JSON array instead of the wrapper object). These only affect--jsonmode; text output is unchanged.The implementation refactors
ListMessagesto accept aListOptionsstruct instead of positional parameters, which makes it cleaner to extend. I can split this into smaller PRs if preferred.Branch:
feat/mail-list-enhancements