Documentation ¶
Index ¶
- Variables
- func Blue(s string) string
- func Bluef(s string, args ...interface{}) string
- func Bold(s string) string
- func Boldf(s string, args ...interface{}) string
- func Cyan(s string) string
- func Cyanf(s string, args ...interface{}) string
- func Dim(s string) string
- func Dimf(s string, args ...interface{}) string
- func FormatAsList(items []string) string
- func FormatDoc(str string) string
- func Green(s string) string
- func Greenf(s string, args ...interface{}) string
- func Magenta(s string) string
- func Magentaf(s string, args ...interface{}) string
- func PrintArray[T any](items []T, cmd *cobra.Command, mappers Mappers[T]) error
- func PrintRows(rows []*DataRow, w io.Writer)
- func Red(s string) string
- func Redf(s string, args ...interface{}) string
- func Truncate(maxWidth int, s string) string
- func Yellow(s string) string
- func Yellowf(s string, args ...interface{}) string
- type DataRow
- type IdAndName
- type Mappers
- type Table
- type TableDefinition
Constants ¶
This section is empty.
Variables ¶
View Source
var (
IsColorEnabled = os.Getenv("NO_COLOR") == "" && term.IsTerminal(int(os.Stdout.Fd()))
)
Functions ¶
func FormatAsList ¶ added in v0.7.0
Types ¶
type DataRow ¶ added in v0.7.0
func NewDataRow ¶ added in v0.7.0
type IdAndName ¶
Common struct used for rendering JSON summaries of things that just have an ID and a Name
type Mappers ¶
type Mappers[T any] struct { // A function which will convert T into an output structure suitable for json.Marshal (e.g. IdAndName). // If you leave this as nil, then the command will simply not support output as JSON and will // fail if someone asks for it Json func(item T) any // A function which will convert T into ?? suitable for table printing // If you leave this as nil, then the command will simply not support output as // a table and will fail if someone asks for it Table TableDefinition[T] // A function which will convert T into a string suitable for basic text display // If you leave this as nil, then the command will simply not support output as basic text and will // fail if someone asks for it Basic func(item T) string }
carries conversion functions used by PrintArray and potentially other output code in future
type TableDefinition ¶
Click to show internal directories.
Click to hide internal directories.