Documentation
¶
Overview ¶
Package textx holds the small text helpers every command shares, so a column is cut, an empty value is marked and an age is spelled one way.
Index ¶
- func Age(now, then time.Time) string
- func AppendNote(notes []string, note string) []string
- func Cut(s string, n int) string
- func FirstLine(s string) string
- func JoinAnd(items []string) string
- func JoinOr(items []string) string
- func OrDash(s string) string
- func Plural(n int, one, many string) string
- func Width(s string) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Age ¶
Age is a duration read at a glance: seconds under a minute, then the largest whole unit that fits (12m, 5h, 3d). A future time is 0s.
func AppendNote ¶
AppendNote appends note unless it is empty.
func Cut ¶
Cut shortens s to n terminal columns, an ellipsis marking the cut. Columns, not bytes or runes, because a wide character takes two. An n below 1 leaves s whole, since a caller with no width has no limit.
func JoinAnd ¶ added in v0.65.0
JoinAnd joins items as a sentence does: "a", "a and b", "a, b and c".
Types ¶
This section is empty.