๐ A lightweight terminal printing toolkit for Go CLIs.
Who else is bored with boring grey text in CLIs? ๐๐ปโโ๏ธ
We all have fancy terminals, utf-8 is everywhere, no one is still using the stock windows command prompt any more... are they? ๐คจ
msg
is a tiny toolkit to make rendering beautiful looking output from CLIs as easy as possible in Go.
It's so easy, you already know how it works!
go get github.com/FollowTheProcess/msg@latest
The demo screenshot at the top of the page will get you:
Not bad! ๐
msg
has 5 message types:
- Title - Section header for a block of output
- Info - General info, status updates etc.
- Success - Your CLI has successfully done something
- Warn - Warn the user about something e.g. ignoring hidden files
- Error - Something has gone wrong in your application
All have a single trailing newline automatically applied except Title
which has 1 leading and 2 trailing newlines to create separation.
msg.Error("My error message, underlying error: %v", err) // Newlines are handled for you
// i.e. you don't need to do this
msg.Error("My error message, underlying error: %v\n", err)
// Titles are effectively "\n{your title}\n\n"
msg.Title("My title") // Is enough to get separation in sections of output
By default, every function in msg
prints to os.Stdout
with the exception of msg.Error
which prints to os.Stderr
.
msg
also exports "F-style" print functions which can write to any io.Writer
e.g:
buf := &bytes.Buffer{} // is an io.Writer
msg.Ferror(buf, "My error message")
This package was created with copier and the FollowTheProcess/go_copier project template.