diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..f96dba9 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,21 @@ +# Changelog + +All notable changes to this project are documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +Targeted for the 0.2.6 release. + + +### Added +- `mail batch` subcommand: execute multiple label/unlabel/archive/move/flag/delete + operations from a JSON array over a single IMAP session, with per-op validation and + an optional `--stop-on-error` flag. Reported by @Juan-de-Costa-Rica (#10). +- Server-side filtering for `mail list` (`--unread` via IMAP `SEARCH UNSEEN`, new + `--flagged` via `SEARCH FLAGGED`), additional envelope fields (`from_address`, `to`, + `message_id`, `in_reply_to`), and `--fields` selection. Reported by @Juan-de-Costa-Rica (#9). +- `PM_CLI_BRIDGE_PASSWORD` environment variable as a fallback for the Bridge password, + for headless/no-keyring environments. Reported by @Juan-de-Costa-Rica (#8). diff --git a/docs/batch-format.md b/docs/batch-format.md new file mode 100644 index 0000000..795fc31 --- /dev/null +++ b/docs/batch-format.md @@ -0,0 +1,70 @@ +# Batch Operation Format + +`pm-cli mail batch` reads a JSON array of operations from stdin (or from a file via `--file`) and executes them in order over a single IMAP connection. + +## Input + +A JSON array of operation objects: + +```json +[ + {"op": "label", "uids": ["uid:123"], "label": "Important"}, + {"op": "flag", "uids": ["uid:456"], "read": true}, + {"op": "archive", "uids": ["uid:789"]} +] +``` + +Input is limited to 10MB. An empty array, malformed JSON, or any invalid operation causes the whole batch to be rejected **before** a connection is opened — nothing is executed. + +## Operation fields + +| Field | Type | Applies to | Description | +|-------|------|-----------|-------------| +| `op` | string | all | One of `label`, `unlabel`, `archive`, `move`, `flag`, `delete`. **Required.** | +| `uids` | string[] | all | Message selectors — `uid:` or a bare sequence number. **Required, non-empty.** Do not mix UID and sequence selectors within one operation. | +| `mailbox` | string | all | Source mailbox. Defaults to `INBOX`. | +| `label` | string | `label`, `unlabel` | Label name (mapped to the `Labels/` folder). **Required** for these ops. | +| `to` | string | `move` | Destination mailbox. **Required** for `move`. | +| `read` | bool | `flag` | Mark messages read (`\Seen`). | +| `unread` | bool | `flag` | Mark messages unread (remove `\Seen`). | +| `star` | bool | `flag` | Star messages (`\Flagged`). | +| `unstar` | bool | `flag` | Unstar messages (remove `\Flagged`). | + +A `flag` operation requires at least one of `read`, `unread`, `star`, `unstar`. + +Mailbox and label names containing IMAP special characters (`{`, `*`, `%`, CR, LF) are rejected. + +## Operations + +| op | Effect | +|----|--------| +| `label` | Copies the messages into `Labels/