Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pior/colorfmt
Golang ANSI-colors library based on tags
https://github.com/pior/colorfmt
Last synced: 2 days ago
JSON representation
Golang ANSI-colors library based on tags
- Host: GitHub
- URL: https://github.com/pior/colorfmt
- Owner: pior
- License: mit
- Created: 2018-12-15T21:38:43.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-16T14:21:21.000Z (about 6 years ago)
- Last Synced: 2024-12-04T18:41:22.315Z (about 2 months ago)
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Colorfmt
Golang ANSI-colors library based on inlined tags.
## Install
```
go get -u github.com/dolab/colorize
```## Usage
```go
package mainimport (
"os""github.com/pior/colorfmt"
)func main() {
colorfmt.Printf("{red+bh}-> {yellow+h}Go to {link}%s", "https://wikipedia.com")
colorfmt.Printf(" {white+bh}NOW !!{reset}\n")text := "{Red+bh}Warning: {yellow}this some color\n"
colorfmt.New(os.Stderr, true).Printf(text) // To stdout
colorfmt.New(os.Stderr, false).Printf(text) // Without color
}
```## Tag format
Format: `fgColor+fgAttributes:bgColor+bgAttributes`
Examples:
- `{red}` (red text)
- `{yellow:bh}` (bold light-yellow text)
- `{red+white:h}` (red text on light-white background)Colors:
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
- 0...255 (256 colors)Foreground Attributes:
- B = Blink
- b = bold
- h = high intensity (bright)
- i = inverse
- s = strikethrough
- u = underlineBackground Attributes:
- h = high intensity (bright)Special tags:
- `{reset}`: emit a reset ANSI code to clear all coloring/styling
- `{link}`: simulate the style of a clickable hypertext link## License
[MIT](https://github.com/pior/colorfmt/blob/master/LICENSE)