Skip to content

feat: download-attachments for comments & documents, shared download helper#148

Merged
brigleb merged 3 commits intoneedmore:mainfrom
brianevanmiller:brianevanmiller/attachment-download
Feb 24, 2026
Merged

feat: download-attachments for comments & documents, shared download helper#148
brigleb merged 3 commits intoneedmore:mainfrom
brianevanmiller:brianevanmiller/attachment-download

Conversation

@brianevanmiller
Copy link
Contributor

Add comment download-attachments and document download-attachments commands so attachments can be downloaded from any Basecamp resource type. Add --include-comments flag to card, todo, message, and document download-attachments to also pull attachments from comments on those resources.

  • Extract shared internal/download package with DownloadFromSources() helper, eliminating ~450 lines of near-identical code across the three existing download commands
  • bc4 comment download-attachments <id|url> — download attachments from a comment
  • bc4 document download-attachments <id|url> — download attachments from a document
  • --include-comments flag on card/todo/message/document download-attachments fetches comment attachments too, with [source label] prefixes to identify where each file came from
  • Show attachment info in comment view output (matches existing card/todo view behavior)
  • Comprehensive test coverage for the shared download helper (14 test cases covering success, errors, blob URLs, file-exists handling, multi-source, attachment indexing)
  • Update README and CHANGELOG
bc4 comment download-attachments 67890
bc4 document download-attachments 12345
bc4 card download-attachments 99999 --include-comments
bc4 todo download-attachments 55555 --include-comments --output-dir ~/Downloads

…nload helper

- Add `comment download-attachments` and `document download-attachments` commands
- Add `--include-comments` flag to card/todo/message/document download-attachments
- Extract shared `internal/download` package, eliminating ~450 lines of duplication
- Show attachments in `comment view` output
- Add comprehensive tests for the shared download helper

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@brianevanmiller
Copy link
Contributor Author

@brigleb - some more enhancements for my AI agents to use 😊

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds new CLI support for downloading attachments from additional Basecamp resource types while consolidating shared download logic into a reusable internal helper.

Changes:

  • Introduces bc4 comment download-attachments and bc4 document download-attachments commands.
  • Adds --include-comments to existing download-attachments commands (card/todo/message/document) to also fetch attachments from comments.
  • Extracts shared attachment download logic into internal/download with accompanying unit tests; updates README + CHANGELOG.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/download/download.go New shared helper to parse attachment HTML and download uploads with consistent CLI output and summary.
internal/download/download_test.go Unit tests for the shared helper (multi-source, overwrite/skip behavior, attachment indexing, blob URL handling, helpers).
internal/api/pagination.go Minor formatting cleanup in PaginatedRequest struct alignment.
cmd/card/download_attachments.go Replaces in-command download logic with shared helper; adds --include-comments.
cmd/todo/download_attachments.go Replaces in-command download logic with shared helper; adds --include-comments.
cmd/message/download_attachments.go Replaces in-command download logic with shared helper; adds --include-comments.
cmd/document/download_attachments.go New document attachment download command (with --include-comments).
cmd/document/document.go Registers the new document download-attachments subcommand.
cmd/comment/download_attachments.go New comment attachment download command.
cmd/comment/comment.go Registers the new comment download-attachments subcommand.
cmd/comment/view.go Adds attachment display to comment view output (matching other view commands).
README.md Documents new commands and --include-comments; updates blob URL limitation guidance.
CHANGELOG.md Adds Unreleased entries for new commands/flag and refactor.

brianevanmiller and others added 2 commits February 24, 2026 10:05
…test cleanup

- Deduplicate filenames when multiple attachments share the same name (e.g., image.png → image_1.png)
- Reject Windows-reserved device names (CON, PRN, NUL, COM1-9, LPT1-9) in SanitizeFilename
- Fix os.Getwd() error handling in test, use t.Cleanup for directory restore
- Add tests for deduplication and Windows reserved names

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Blob storage URLs are expected to be undownloadable via OAuth and
shouldn't cause a non-zero exit code. They're now counted as skipped
with a warning, matching the existing file-exists skip behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@brigleb brigleb merged commit ee6302f into needmore:main Feb 24, 2026
2 checks passed
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.

3 participants