feat(gmail): add forward command with attachment support#474
Open
brettdavies wants to merge 2 commits intosteipete:mainfrom
Open
feat(gmail): add forward command with attachment support#474brettdavies wants to merge 2 commits intosteipete:mainfrom
brettdavies wants to merge 2 commits intosteipete:mainfrom
Conversation
Add `gog gmail forward <messageId>` command that forwards an email with all original attachments in a single command. Supports --to, --cc, --bcc, --subject, --body/--body-file, --from, --attach (local files), and --no-attachments flags. Reuses existing helpers (buildRFC822, resolveComposeFrom, collectAttachments, fetchAttachmentBytes, writeSendResults) without modifying any existing files beyond command registration in gmail.go. Closes steipete#166 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Set ThreadId on the sent message to keep the forward in the sender's thread, matching Gmail web UI behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
brettdavies
added a commit
to brettdavies/dotfiles
that referenced
this pull request
Mar 24, 2026
Requirements and implementation plan for contributing a gmail forward command to steipete/gogcli. PR submitted as steipete/gogcli#474. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
gog gmail forward <messageId>command that forwards an email with all original attachments in a single command. Closes #166.New flags:
--to,--cc,--bcc,--subject,--body,--body-file,--from,--attach(repeatable),--no-attachmentsScope
gmail forwardin the "Write" group (alias:fwd)--no-attachmentsto strip them--attachadds additional local files alongside forwarded attachments--subjectto override--body/--body-file, inserted before forwarded header block--fromfor send-as alias support via existingresolveComposeFrom()--json/--plainoutput consistent withgmail sendThreadIdon the sent message so the forward stays in the sender's thread, matching Gmail web UI behaviorbuildRFC822,resolveComposeFrom,collectAttachments,fetchAttachmentBytes,writeSendResults) — no existing files modified beyond 1-line command registration ingmail.goDesign notes
resolveComposeFrom()directly instead of creating a newresolveSendFrom()— avoids modifyinggmail_send.go--attachfor local files and--no-attachmentsto strip originalsThreadIdon sent message)--to) matchinggmail sendpattern, not positional argsTesting
gmail_forward_test.go): 30 subtests coveringforwardSubject,forwardHeaderPlain/HTML,buildForwardBodies,plainToHTML,joinForwardSectionsexecute_gmail_forward_test.go): 7 tests viaExecute()with httptest mock servers:--no-attachmentsstrips originals--attachadds local files alongside originals--no-attachments+--attachreplaces originals with localsgo test ./...)Known limitations (v1)
--body-htmlfor rich-text preface (plain text auto-escaped for HTML variant)Files
Created:
internal/cmd/gmail_forward.go(264 lines) — command + helpersinternal/cmd/gmail_forward_test.go(424 lines) — unit testsinternal/cmd/execute_gmail_forward_test.go(763 lines) — integration testsModified:
internal/cmd/gmail.go(+1 line) — command registration