https://github.com/dollarshaveclub/line
An easy to use golang package for stylizing terminal output
https://github.com/dollarshaveclub/line
ansi-colors color colors go golang terminal
Last synced: 7 months ago
JSON representation
An easy to use golang package for stylizing terminal output
- Host: GitHub
- URL: https://github.com/dollarshaveclub/line
- Owner: dollarshaveclub
- License: mit
- Created: 2017-12-18T20:08:02.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-01-02T23:44:08.000Z (almost 6 years ago)
- Last Synced: 2025-03-21T15:11:04.623Z (7 months ago)
- Topics: ansi-colors, color, colors, go, golang, terminal
- Language: Go
- Homepage:
- Size: 55.7 KB
- Stars: 27
- Watchers: 48
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# line
[](http://godoc.org/github.com/dollarshaveclub/line)
[](https://circleci.com/gh/dollarshaveclub/line/tree/master)
[](https://goreportcard.com/report/github.com/dollarshaveclub/line)
line is an easy to use package for stylizing terminal output. line focuses on usability via chaining and, consequently, is quite flexible. line also boasts compatibility with the popular [Color](https://github.com/fatih/color) package.
## Install
```bash
go get github.com/dollarshaveclub/line
```
## Usage
### Simple
```go
package main
import "github.com/dollarshaveclub/line"
func main() {
line.Red().Print("Hello ").Green("World").Blue().Println("!!!")
}
```

### Prefix / Suffix
```go
package main
import "github.com/dollarshaveclub/line"
func main() {
line.Prefix("--> ").Suffix(" <---").Println("Nice to meet you!").Println("And you too!")
}
```

### Complex
```go
package main
import (
"os"
"github.com/dollarshaveclub/line"
"github.com/fatih/color"
)
func main() {
output := line.New(os.Stdout, "", "", line.WhiteColor)
output.Println("Welcome! Here is a list:")
li := output.Prefix("--> ").Red()
li.Println("one").Println("two").Println("sub")
subli := li.Prefix(" --> ").Green()
subli.Println("a").Println("b")
output.Println()
boldgreen := color.New(color.Bold, color.FgMagenta)
output.Format(boldgreen).Println("Have a nice day!")
}
```
