mirror of
https://gitea.com/gitea/tea.git
synced 2026-06-05 18:58:43 +02:00
28ba9b915b
Reviewed-on: https://gitea.com/gitea/tea/pulls/1006 Reviewed-by: Zettat123 <39446+zettat123@noreply.gitea.com>
35 lines
616 B
Go
35 lines
616 B
Go
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package print
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"gitea.dev/sdk"
|
|
)
|
|
|
|
func formatByteSize(size int64) string {
|
|
if size < 1024 {
|
|
return fmt.Sprintf("%d B", size)
|
|
}
|
|
return formatSize(size / 1024)
|
|
}
|
|
|
|
// ReleaseAttachmentsList prints a listing of release attachments
|
|
func ReleaseAttachmentsList(attachments []*gitea.Attachment, output string) error {
|
|
t := tableWithHeader(
|
|
"Name",
|
|
"Size",
|
|
)
|
|
|
|
for _, attachment := range attachments {
|
|
t.addRow(
|
|
attachment.Name,
|
|
formatByteSize(attachment.Size),
|
|
)
|
|
}
|
|
|
|
return t.print(output)
|
|
}
|