feat(attachment): download attachments under their own name

issue attachment download (and pr attachment download) required
--output-file. It now writes ./<name> like gh release download, refusing
to replace an existing file unless --clobber (or --skip-existing to keep
it), with -O/--output and -D/--dir from the shared download flags.
attachment list shows ID NAME SIZE DOWNLOADS CREATED with readable
sizes, attachment view is a view, and upload, rename and delete report
✓ lines; delete names the attachment in its confirmation. The commands
accept issue and pull request URLs and have help text with examples.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-12 00:17:05 +02:00
1 parent 0f090654a4
commit e5796af9e9
5 files changed
+192 -126

No files matched your search

+6 -4
View File
@@ -65,11 +65,13 @@ func (s Issues) UploadAttachment(ctx context.Context, number int64, name string,
return IssueAttachment(asset), err
}
// DownloadAttachment opens an attachment stream scoped to its instance and issue.
func (s Issues) DownloadAttachment(ctx context.Context, number, id int64) (io.ReadCloser, error) {
// DownloadAttachment opens an attachment stream scoped to its instance and issue, and returns the
// attachment's metadata.
func (s Issues) DownloadAttachment(ctx context.Context, number, id int64) (IssueAttachment, io.ReadCloser, error) {
attachment, err := s.attachment(ctx, number, id)
if err != nil {
return nil, err
return IssueAttachment{}, nil, err
}
return downloadAttachment(ctx, s.Client, attachment)
body, err := downloadAttachment(ctx, s.Client, attachment)
return IssueAttachment(assetFrom(attachment)), body, err
}