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 Error(format string, a ...any)
- 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 Error ¶ added in v0.6.0
Error prints an error message with optional format args to stderr.
Example ¶
msg.Error("Invalid config") msg.Error("Could not find file: %s", "missing.txt")
func Ferror ¶ added in v0.6.0
Ferror prints an error message with optional format args to w.
Example ¶
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.
Example ¶
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.
Example ¶
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.
Example ¶
msg.Ftitle(os.Stdout, "Some section")
func Fwarn ¶ added in v0.6.0
Fwarn prints a warning message with optional format args to w.
Example ¶
msg.Fwarn(os.Stderr, "hmmmm: %v", true)
func Info ¶
Info prints an info message with optional format args to stdout.
Example ¶
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.
Example ¶
msg.Success("Compiled project: %s", "msg")
Types ¶
This section is empty.