Documentation
¶
Overview ¶
Package msg is a simple, easy to use, opinionated console printing toolkit for Go CLIs rendering pretty formatted output with colours specific to the particular message type:
- Info: For general user information and progress updates
- Title: Separation between sections of output
- Warn: User warnings
- Success: Report success
- Error: Report failure
All message types default to stdout other than the `Error` type which prints to stderr by default.
There are also "F-style" print methods that allow you to specify an io.Writer to print the messages to.
Index ¶
- func Err(err error)
- func Error(format string, a ...any)
- func Ferr(w io.Writer, err error)
- func Ferror(w io.Writer, format string, a ...any)
- func Finfo(w io.Writer, format string, a ...any)
- func Fsuccess(w io.Writer, format string, a ...any)
- func Ftitle(w io.Writer, format string, a ...any)
- func Fwarn(w io.Writer, format string, a ...any)
- func Info(format string, a ...any)
- func Success(format string, a ...any)
- func Title(format string, a ...any)
- func Warn(format string, a ...any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Err ¶ added in v1.3.0
func Err(err error)
Err is a convenience wrapper around Error allowing passing an error directly without the need for the %v format verb.
err := errors.New("Uh oh!")
msg.Err(err) // Equivalent to msg.Error("%v", err)
func Error ¶ added in v0.6.0
Error prints an error message with optional format args to stderr.
msg.Error("Invalid config")
msg.Error("Could not find file: %s", "missing.txt")
func Ferr ¶ added in v1.3.0
Ferr is a convenience wrapper around Ferror allowing passing an error directly without the new for the %v format verb.
It is the 'F' equivalent of Err, taking an io.Writer to print the error to.
err := errors.New("Uh oh!")
msg.Ferr(os.Stderr, err) // Equivalent to msg.Ferror(os.Stderr, "%v", err)
func Ferror ¶ added in v0.6.0
Ferror prints an error message with optional format args to w.
msg.Ferror(os.Stderr, "Uh oh! %s", "something wrong")
func Finfo ¶ added in v0.6.0
Finfo prints an info message with optional format args to w.
msg.Finfo(os.Stdout, "The meaning of life is %v", 42)
func Fsuccess ¶ added in v0.6.0
Fsuccess prints a success message with optional format args to w.
msg.Fsuccess(os.Stdout, "Compiled project: %s", "msg")
func Ftitle ¶ added in v0.6.0
Ftitle prints a title message to w.
A title message differs from every other message type in msg as it has 1 leading newline and 2 trailing newlines to create separation between the sections it is differentiating in your CLI.
msg.Ftitle(os.Stdout, "Some section")
func Fwarn ¶ added in v0.6.0
Fwarn prints a warning message with optional format args to w.
msg.Fwarn(os.Stderr, "hmmmm: %v", true)
func Info ¶
Info prints an info message with optional format args to stdout.
msg.Info("You have %d repos on GitHub", 42)
func Success ¶ added in v0.6.0
Success prints a success message with optional format args to stdout.
msg.Success("Compiled project: %s", "msg")
Types ¶
This section is empty.