add helper for printing issue list.

add helper for converting issue pointer to issue
This commit is contained in:
Robin Olsen
2026-02-05 12:49:23 +01:00
parent d3911ec1f9
commit 7e0c45e9a2

View File

@@ -1,6 +1,13 @@
package models
import "github.com/steveyegge/beads"
import (
"fmt"
"os"
"text/tabwriter"
"github.com/muesli/reflow/truncate"
"github.com/steveyegge/beads"
)
type (
Issue = beads.Issue
@@ -71,3 +78,35 @@ const (
EventLabelRemoved = beads.EventLabelRemoved
EventCompacted = beads.EventCompacted
)
func IssuesPtrToIssues(issuePtr []*Issue) []Issue {
issues := make([]Issue, 0, len(issuePtr))
for _, issue := range issuePtr {
issues = append(issues, *issue)
}
return issues
}
func FormatIssueRow(issue Issue) string {
return fmt.Sprintf(
"%s\t%s\t%s\t%s\t%s\t%d",
truncate.String(issue.ID, 5),
truncate.StringWithTail(issue.Title, 25, "..."),
truncate.StringWithTail(issue.Description, 40, "..."),
issue.Status,
issue.IssueType,
issue.Priority,
)
}
func PrintIssues(issues []Issue) {
w := tabwriter.NewWriter(os.Stdout, 8, 10, 5, ' ', 0)
fmt.Fprintln(w, "ID\tTITLE\tDESCRIPTION\tSTATUS\tTYPE\tPRIORITY")
for _, issue := range issues {
fmt.Fprintln(w, FormatIssueRow(issue))
}
w.Flush()
}