docs(cli): update developer CLI documentation and add nerd font requirement
This commit is contained in:
6 files changed
+578
-46
No files matched your search
@@ -3,6 +3,7 @@ package ui
|
||||
import (
|
||||
"fmt"
|
||||
"image/color"
|
||||
"strings"
|
||||
|
||||
"charm.land/lipgloss/v2"
|
||||
)
|
||||
@@ -190,8 +191,8 @@ func Bar(percent float64, width int, colour color.Color) string {
|
||||
}
|
||||
filled := int(percent * float64(width))
|
||||
empty := width - filled
|
||||
return lipgloss.NewStyle().Foreground(colour).Render(repeat("█", filled)) +
|
||||
lipgloss.NewStyle().Foreground(Faint).Render(repeat("░", empty))
|
||||
return lipgloss.NewStyle().Foreground(colour).Render(strings.Repeat("█", filled)) +
|
||||
lipgloss.NewStyle().Foreground(Faint).Render(strings.Repeat("░", empty))
|
||||
}
|
||||
|
||||
// Percent formats a fraction for display next to a bar.
|
||||
|
||||
@@ -53,25 +53,15 @@ func Panel(title string, focused bool) lipgloss.Style {
|
||||
// Rule draws a labelled separator across the given width.
|
||||
func Rule(label string, width int) string {
|
||||
if width < 8 {
|
||||
return Dim.Render(label)
|
||||
return Dim.Render(Truncate(label, width))
|
||||
}
|
||||
prefix := "── " + label + " "
|
||||
if lipgloss.Width(prefix) >= width {
|
||||
return Dim.Render(prefix[:width])
|
||||
prefixWidth := lipgloss.Width(prefix)
|
||||
if prefixWidth >= width {
|
||||
return Dim.Render(Truncate(prefix, width))
|
||||
}
|
||||
fill := width - lipgloss.Width(prefix)
|
||||
return Dim.Render(prefix + repeat("─", fill))
|
||||
}
|
||||
|
||||
func repeat(char string, count int) string {
|
||||
if count <= 0 {
|
||||
return ""
|
||||
}
|
||||
out := make([]byte, 0, count*len(char))
|
||||
for range count {
|
||||
out = append(out, char...)
|
||||
}
|
||||
return string(out)
|
||||
fill := width - prefixWidth
|
||||
return Dim.Render(prefix + strings.Repeat("─", fill))
|
||||
}
|
||||
|
||||
// Blank reports whether a line would render as empty. Build tools emit lines
|
||||
|
||||
Reference in new issue
Block a user