Categorygithub.com/FollowTheProcess/msg
modulepackage
1.2.0
Repository: https://github.com/followtheprocess/msg.git
Documentation: pkg.go.dev

# README

msg

License Go Reference Go Report Card GitHub CI codecov

๐Ÿš€ A lightweight terminal printing toolkit for Go CLIs.

demo

Project Description

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!

Installation

go get github.com/FollowTheProcess/msg@latest

Quickstart

The demo screenshot at the top of the page will get you:

output

Not bad! ๐Ÿš€

User Guide

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

Stdout/Stderr

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")

Credits

This package was created with copier and the FollowTheProcess/go_copier project template.

# Packages

No description provided by the author

# Functions

Error prints an error message with optional format args to stderr.
Ferror prints an error message with optional format args to w.
Finfo prints an info message with optional format args to w.
Fsuccess prints a success message with optional format args to w.
Ftitle prints a title message to w.
Fwarn prints a warning message with optional format args to w.
Info prints an info message with optional format args to stdout.
Success prints a success message with optional format args to stdout.
Title prints a title message to stdout.
Warn prints a warning message with optional format args to stdout.