Skip to content
/ ansi Public

a small (Go) package to generate ansi-styling and coloring strings

License

Notifications You must be signed in to change notification settings

ninlil/ansi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

columns

a small package to generate ansi-styling and coloring strings

Go Report Card

Getting Started

Installing

Just do a go get on this package and your good to go.

go get github.com/ninlil/ansi

Features

  • Static or dynamic effect support
  • No dependencies
  • Stringer-interface compatible

Examples

Static example:

fmt.Printf("Here is a %stext in green%s", ansi.Green, ansi.Default)

Dynamic styling:

func checkTemp(temp float64) {
	fmt.Printf("temp is %s%v%s\n", ansi.Green.YellowFore(temp > 65).RedFore(temp > 100), temp, ansi.Default)
}
...
checkTemp(37.5)  // will print value in green
checkTemp(73.5)  // will print value in yellow
checkTemp(105.5) // will print value in red

Different coding styles:

error1 := ansi.Red.Background() | ansi.Yellow | ansi.Bright
error2 := ansi.NewStyle(ansi.Red.Background(), ansi.Yellow, ansi.Bright)
error3 := (ansi.Yellow | ansi.Bright).RedBack(true)

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Code usage

Authors

  • ninlil - Initial work - ninlil

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

a small (Go) package to generate ansi-styling and coloring strings

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages