Skip to content

feat(gmail): show attachment info in get command output#83

Merged
steipete merged 5 commits intoopenclaw:mainfrom
jeanregisser:feature/show-attachments-in-get
Jan 17, 2026
Merged

feat(gmail): show attachment info in get command output#83
steipete merged 5 commits intoopenclaw:mainfrom
jeanregisser:feature/show-attachments-in-get

Conversation

@jeanregisser
Copy link
Copy Markdown
Contributor

@jeanregisser jeanregisser commented Jan 16, 2026

Summary

Display attachment filename, size, MIME type, and attachment_id in both plain text and JSON output for the gmail get command with --format=full.

This makes it easier to identify and download attachments without needing to manually parse the message payload structure.

Problem

When using gog gmail get <messageId>, there's no indication of attachments in the output. Users need to use --format=full --json and then manually parse the nested message.payload.parts structure to find attachment IDs before they can use gog gmail attachment to download them.

Solution

Reuse the existing collectAttachments() function from gmail_thread.go to extract and display attachment info in both output formats.

Example plain text output (new section before body):

from	a@example.com
to	b@example.com
subject	Email with attachment
date	Fri, 26 Dec 2025 10:00:00 +0000

attachment	CV-Document.pdf	192123	application/pdf	ANGjdJ...

hello with attachment

Example JSON output (new field):

{
  "attachments": [
    {"filename": "CV-Document.pdf", "size": 192123, "mimeType": "application/pdf", "attachmentId": "ANGjdJ..."}
  ]
}

AI-Assisted Development

This PR was created with AI assistance. The prompts used:

Initial prompt:

I wonder if the gog cli email output should be improved to include info about attachments?

Follow-up prompt:

Yes it's a repo from steipete, I think we could propose a PR directly with a proposed solution given the problem we had. Can you take care of it? Give a link to the PR once done. Include the prompts used in the PR too I think it's helpful for the maintainer

Context: The user was trying to download an email attachment and struggled because gog gmail get didn't show attachment info. They had to:

  1. Use gog gmail get <id> --format=full --json
  2. Parse the JSON to find .message.payload.parts[].body.attachmentId
  3. Then use gog gmail attachment <messageId> <attachmentId>

With this change, the attachment ID is visible directly in the standard output.

jeanregisser and others added 5 commits January 17, 2026 05:47
Display attachment filename, size, MIME type, and attachment_id in both
plain text and JSON output for the 'gmail get' command with --format=full.

This makes it easier to identify and download attachments without needing
to manually parse the message payload structure.

Example plain text output:
  attachments:
    CV-Document.pdf (192123 bytes, application/pdf)
      attachment_id	ANGjdJ...

Example JSON output (new field):
  "attachments": [
    {"Filename": "CV-Document.pdf", "Size": 192123, ...}
  ]
Add two test cases:
- TestGmailGetCmd_JSON_Full_WithAttachments: verifies attachments array
  is present in JSON output with correct filename, size, mime type, and ID
- TestGmailGetCmd_Text_Full_WithAttachments: verifies plain text output
  includes attachment info section with all expected fields
Use camelCase field names (filename, size, mimeType, attachmentId)
to be consistent with the rest of the JSON output (messageId, labelIds, etc.)
Use tab-separated format like other gog commands:
  attachment\t<filename>\t<size>\t<mimeType>\t<attachmentId>

This matches the pattern used in calendar_print.go (attendee, attachment)
and drive.go for array data.
@steipete steipete force-pushed the feature/show-attachments-in-get branch from 34d8fc6 to 67eb0d9 Compare January 17, 2026 05:54
@steipete steipete merged commit 6c374ea into openclaw:main Jan 17, 2026
1 check passed
@steipete
Copy link
Copy Markdown
Collaborator

Landed via temp rebase onto main.

  • Gate: pnpm lint && pnpm build && pnpm test
  • Land commit: 67eb0d9
  • Merge commit: 6c374ea

Thanks @jeanregisser!

@jeanregisser jeanregisser deleted the feature/show-attachments-in-get branch January 17, 2026 06:26
klodr pushed a commit to klodr/gogcli that referenced this pull request Apr 22, 2026
klodr pushed a commit to klodr/gogcli that referenced this pull request Apr 22, 2026
…ents-in-get

feat(gmail): show attachment info in get command output
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