Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,13 @@ inboxapi get-email "<message-id>"

### `delete-email`

Soft-deletes a received email by message ID. It prompts for confirmation by default, and scripted or piped use must pass `--force`.
Archives (soft-deletes) a received email by message ID. It prompts for confirmation by default, and scripted or piped use must pass `--force`.
`archive-email` is available as an alias for `delete-email`.

```bash
inboxapi delete-email "<message-id>"
inboxapi delete-email "<message-id>" --force
inboxapi archive-email "<message-id>" --force
```

### `search-emails`
Expand Down
3 changes: 3 additions & 0 deletions docs/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ inboxapi send-email --to user@example.com --subject "Hello" --body "Hi there"
inboxapi send-email --to user@example.com --subject "Newsletter" --body-file ./body.txt --html-body-file ./newsletter.html
inboxapi get-emails --limit 5 --human
inboxapi delete-email "<message-id>" --force
inboxapi archive-email "<message-id>" --force
inboxapi search-emails --subject "invoice"
inboxapi help
```
Expand Down Expand Up @@ -78,6 +79,7 @@ Your InboxAPI email address (from `whoami`) is **the agent's own inbox** for rec
## Deleting Received Email

Use `delete_email` to hide a received message from the normal inbox views. This is a soft delete: the message is removed from `get_last_email`, `get_emails`, `get_email`, `search_emails`, `get_email_count`, and `get_thread`, but there is no restore or trash command yet.
For CLI usage, `archive-email` is an alias for `delete-email`.

The CLI prompts for confirmation by default. If stdin is not a TTY, you must pass `--force` or it will error instead of deleting.

Expand All @@ -86,6 +88,7 @@ CLI example:
```bash
inboxapi delete-email "<message-id>"
inboxapi delete-email "<message-id>" --force
inboxapi archive-email "<message-id>" --force
```

---
Expand Down
24 changes: 22 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ enum Commands {
/// The message ID to retrieve
message_id: String,
},
/// Soft-delete a received email by message ID
/// Archive (soft-delete) a received email by message ID
#[command(visible_alias = "archive-email")]
DeleteEmail {
/// The message ID to delete
message_id: String,
Expand Down Expand Up @@ -2513,7 +2514,7 @@ Commands:
send-email Send an email (supports --attachment and --attachment-ref)
get-emails List inbox emails
get-email Get a single email by message ID
delete-email Soft-delete a received email by message ID
delete-email Archive (soft-delete) a received email by message ID (alias: archive-email)
get-last-email Get the most recent email
get-email-count Get inbox email count
get-sent-emails List sent emails
Expand Down Expand Up @@ -2549,6 +2550,7 @@ Examples:
inboxapi get-emails --limit 5
inboxapi get-emails --limit 5 --human
inboxapi delete-email \"<msg-id>\" --force
inboxapi archive-email \"<msg-id>\" --force
inboxapi get-last-email
inboxapi get-email-count
inboxapi get-sent-emails --limit 10
Expand Down Expand Up @@ -8129,6 +8131,20 @@ mod tests {
);
}

#[test]
fn test_archive_email_alias_parses_positional_message_id() {
let cli =
Cli::try_parse_from(["inboxapi", "archive-email", "<msg-id>", "--force"]).unwrap();

assert!(
matches!(
cli.command,
Some(Commands::DeleteEmail { message_id, force: true }) if message_id == "<msg-id>"
),
"CLI arguments for archive-email alias should be parsed correctly"
);
}

#[test]
fn test_delete_email_prompt_mode() {
assert!(
Expand Down Expand Up @@ -8830,6 +8846,10 @@ mod tests {
CLI_HELP_TEXT.contains("delete-email"),
"CLI help text should include the delete-email command"
);
assert!(
CLI_HELP_TEXT.contains("archive-email"),
"CLI help text should include the archive-email alias"
);
assert!(
CLI_HELP_TEXT.contains("search-emails"),
"help should include search-emails"
Expand Down
Loading