refactor: remove helpers the new output and prompts left unused

Drop writeDownload, terminal.Require, terminal.Confirm, terminal.Row,
terminal.Record and Pulls.FindOpenByHead, which no command calls anymore,
and point their tests at the code that replaced them.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-12 10:00:05 +02:00
1 parent eff6efe759
commit 50a604f169
8 files changed
+34 -118

No files matched your search

-35
View File
@@ -84,15 +84,6 @@ func (c Cell) style(text string, d Display, link bool) string {
return Hyperlink(c.Link, text, link && d.Links)
}
// Row returns unstyled cells.
func Row(texts ...string) []Cell {
cells := make([]Cell, len(texts))
for i, text := range texts {
cells[i].Text = text
}
return cells
}
// Table renders rows under columns; rows may have more cells than there are columns. On a TTY it
// prints an uppercase header row when any column has a header, aligns columns two spaces apart,
// and shrinks Flex columns until rows fit the display width. Otherwise it writes one line of
@@ -209,32 +200,6 @@ func fitWidth(widths []int, limit int, flex func(j int) (bool, int)) {
}
}
// Record is one item for human readers: a heading line of cells separated by spaces,
// followed by text lines such as a body and a URL.
type Record struct {
Heading []Cell
Lines []string
}
// Render formats the record. Heading cells pass through SafeLine and are styled like
// Table cells; lines pass through SafeText, so they keep their own line breaks.
func (r Record) Render(color bool) string {
d := Display{TTY: true, Color: color, TrueColor: true, Links: color}
var b strings.Builder
for i, cell := range r.Heading {
if i > 0 {
b.WriteByte(' ')
}
b.WriteString(cell.style(SafeLine(cell.Text), d, true))
}
b.WriteByte('\n')
for _, line := range r.Lines {
b.WriteString(SafeText(line))
b.WriteByte('\n')
}
return b.String()
}
// SafeLine reduces server text to one line: SafeText, with tabs and line breaks as spaces.
func SafeLine(s string) string {
return strings.Map(func(r rune) rune {