Skip to content

feat(gmail): add archive, read, unread, trash convenience commands#385

Merged
steipete merged 2 commits intosteipete:mainfrom
yeager:feat/gmail-archive-read-unread-trash
Mar 3, 2026
Merged

feat(gmail): add archive, read, unread, trash convenience commands#385
steipete merged 2 commits intosteipete:mainfrom
yeager:feat/gmail-archive-read-unread-trash

Conversation

@yeager
Copy link

@yeager yeager commented Mar 2, 2026

Summary

Adds four top-level Gmail convenience commands that wrap batch modify:

Command Effect
gog gmail archive Remove INBOX label
gog gmail read Remove UNREAD label
gog gmail unread Add UNREAD label
gog gmail trash Add TRASH + remove INBOX

Usage

# Archive specific messages
gog gmail archive MSG_ID1 MSG_ID2

# Archive all unread older than 7 days
gog gmail archive -q 'is:unread older_than:7d'

# Mark all as read
gog gmail read -q 'is:unread' --max 500

# Trash by query
gog gmail trash -q 'from:noreply@example.com'

Implementation

  • Single new file: internal/cmd/gmail_archive.go
  • Shared gmailBulkLabelOp() helper with auto-batching (1000/request)
  • searchMessageIDs() for query-based bulk operations with pagination
  • Registered as top-level commands under GmailCmd (Organize group)
  • Supports JSON output, dry-run, all standard flags

Daniel Nylander and others added 2 commits March 3, 2026 04:27
New top-level Gmail commands for common label operations:

- `gog gmail archive` — remove INBOX label (archive)
- `gog gmail read` — remove UNREAD label (mark as read)
- `gog gmail unread` — add UNREAD label (mark as unread)
- `gog gmail trash` — add TRASH + remove INBOX label

All commands support:
- Message IDs as positional args: `gog gmail archive ID1 ID2`
- Query-based bulk ops: `gog gmail archive -q 'is:unread older_than:7d'`
- `--max` to limit query results (default 100)
- JSON output with `--json`
- Automatic batching (1000 per request, Gmail API limit)

These wrap the existing `gog gmail batch modify` with ergonomic
shortcuts for the most common Gmail operations.
@steipete steipete force-pushed the feat/gmail-archive-read-unread-trash branch from 9aa0fcf to 31e22ba Compare March 3, 2026 04:33
@steipete steipete merged commit e909bc8 into steipete:main Mar 3, 2026
@steipete
Copy link
Owner

steipete commented Mar 3, 2026

Landed via temp rebase onto main.

  • Gate: make ci (pnpm gate skipped), go test ./internal/cmd -run 'TestGmail(BulkOps_DryRun_UsesSpecificOpsAndLabels|ArchiveCmd_DryRun_QueryMode_NoAccountRequired)$'
  • Land commit: 31e22ba
  • Merge commit: e909bc8

Thanks @yeager!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants