This package provides a simple interface with implementations for printing information in command-line applications.
It supports various verbosity levels as well as formatting styles.
Quick Start
package main
import "github.com/gardenbed/charm/ui"
func main() {
u := ui.New(ui.Info)
u.Infof(ui.Green, "Hello, %s!", "World")
}
const (
// Trace shows all messages. Trace Level = iota// Debug shows Debug, Info, Warn, and Error messages. Debug
// Info shows Info, Warn, and Error messages. Info
// Warn shows Warn and Error messages. Warn
// Error shows only Error messages. Error
// None does not show any messages. None
)
type UI interface {
// Output method independent of the verbosity level Printf(format string, a ...interface{})
// Leveled output methods GetLevel() Level SetLevel(l Level)
Tracef(s Style, format string, a ...interface{})
Debugf(s Style, format string, a ...interface{})
Infof(s Style, format string, a ...interface{})
Warnf(s Style, format string, a ...interface{})
Errorf(s Style, format string, a ...interface{})
}
UI is the interface for interacting with users in command-line applications.