Categorygithub.com/gesquive/cli
modulepackage
0.3.1
Repository: https://github.com/gesquive/cli.git
Documentation: pkg.go.dev

# README

cli

I consistently needed a simple output printer for my console projects that did not require a lot of setup. Since I couldn't find a library to fill this role, I just wrote this project quickly for myself.

Features include:

  • cross-platform colored output
  • automatic tty detection
  • leveled printing

This library is not meant to be a comprehensive logging library. If you need more out of your logging library, I recommend Logrus.

Usage

example.go

package main

import "github.com/gesquive/cli"

func main() {
	cli.SetPrintLevel(cli.LevelInfo)
	cli.Debug("debug")
	cli.Info("info")
	cli.Warn("warn")
	cli.Error("error")
}
debug
info
warn
error

License

This library is made available under an MIT-style license. See LICENSE.

Contributing

PRs are always welcome!

# Functions

Debug prints a formatted debug level message with a newline appended.
Debugf prints a formatted debug level message.
Debugln prints a debug level message with a newline appended.
Error prints a formatted error level message with a newline appended.
Errorf prints a formatted error level message.
Errorln prints an error level message with a newline appended.
Fatal prints a formatted fatal level message with a newline appended and calls os.Exit(1).
Fatalf prints a formatted fatal level message and calls os.Exit(1).
Fatalln prints a fatal level message with a newline appended and calls os.Exit(1).
Info prints a formatted info level message with a newline appended.
Infof prints a formatted info level message.
Infoln prints an info level message with a newline appended.
No description provided by the author
No description provided by the author
SetColor sets the color status.
SetErrorWriter allows you to set the output writer for error and fatal messages.
SetOutputWriter allows you to set the output file for debug, info, and warn messges.
SetPrintLevel allows you to set the level to print, by default LevelInfo is set.
Warn prints a formatted warning level message with a newline appended.
Warnf prints a formatted warning level message.
Warnln prints a warning level message with a newline appended.

# Constants

Print levels go in order: Debug, Info, Warn, Error, Fatal.
Print levels go in order: Debug, Info, Warn, Error, Fatal.
Print levels go in order: Debug, Info, Warn, Error, Fatal.
Print levels go in order: Debug, Info, Warn, Error, Fatal.
Print levels go in order: Debug, Info, Warn, Error, Fatal.

# Variables

Blue creates a blue string.
Green creates a green string.
Red creates a red string.
SprintfBlue creates a blue formatted string.
SprintfGreen creates a green formatted string.
SprintfRed creates a red formatted string.
SprintfYellow creates a yellow formatted string.
Yellow creates a yellow string.

# Structs

No description provided by the author
HandlerOptions is a drop in replacement for [slog.HandlerOptions].