aurora alternatives and similar packages
Based on the "Advanced Console UIs" category.
Alternatively, view aurora alternatives based on common mentions on social networks and blogs.
-
Rich Interactive Widgets for Terminal UIs
Terminal UI library with rich, interactive widgets — written in Golang -
tcell
Tcell is an alternate terminal package, similar in some ways to termbox, but better in others. -
pterm
✨ #PTerm is a modern Go module to easily beautify console output. Featuring charts, progressbars, tables, trees, text input, select menus and much more 🚀 It's completely configurable and 100% cross-platform compatible. -
asciigraph
Go package to make lightweight ASCII line graph ╭┈╯ in command line apps with no other dependencies. -
termtables
DISCONTINUED. A Go port of the Ruby library terminal-tables for simple ASCII table generation as well as providing markdown and HTML output -
chalk
Intuitive package for prettifying terminal/console output. http://godoc.org/github.com/ttacon/chalk -
yacspin
Yet Another CLi Spinner; providing over 80 easy to use and customizable terminal spinners for multiple OSes -
GCli
🖥 Go CLI application, tool library, running CLI commands, support console color, user interaction, progress display, data formatting display, generate bash/zsh completion add more features. Go的命令行应用,工具库,运行CLI命令,支持命令行色彩,用户交互,进度显示,数据格式化显示,生成bash/zsh命令补全脚本 -
ctc
Console Text Colors - The non-invasive cross-platform terminal color library does not need to modify the Print method -
crab-config-files-templating
Dynamic configuration file templating tool for kubernetes manifest or general configuration files
CodeRabbit: AI Code Reviews for Developers
Do you think we are missing an alternative of aurora or a related project?
Popular Comparisons
README
Aurora
Ultimate ANSI colors for Golang. The package supports Printf/Sprintf etc.
TOC
- Installation
- Usage
- Chains
- Colorize
- Grayscale
- 8-bit colors
- Supported Colors & Formats
- Limitations
- Licensing
Installation
Version 1.x
Using gopkg.in.
go get -u gopkg.in/logrusorgru/aurora.v1
Version 2.x
go get -u github.com/logrusorgru/aurora
Go modules support, version v3+
Get
go get -u github.com/logrusorgru/aurora/v3
The v3 was introduced to support go.mod
and leave previous import paths as is.
Currently, there is no changes between them (excluding the importpath's /v3 tail).
The latest version
go get -u github.com/logrusorgru/aurora/v4
With hyperlinks.
Test
go test -cover -race github.com/logrusorgru/aurora/v4
Replace the import path with your, if it's different.
Usage
Simple
package main
import (
"fmt"
"github.com/logrusorgru/aurora/v4"
)
func main() {
fmt.Println("Hello,", aurora.Magenta("Aurora"))
fmt.Println(aurora.Bold(aurora.Cyan("Cya!")))
}
Printf
package main
import (
"fmt"
"github.com/logrusorgru/aurora/v4"
)
func main() {
fmt.Printf("Got it %d times\n", aurora.Green(1240))
fmt.Printf("PI is %+1.2e\n", aurora.Cyan(3.14))
}
aurora.Sprintf
package main
import (
"fmt"
"github.com/logrusorgru/aurora/v4"
)
func main() {
fmt.Println(aurora.Sprintf(aurora.Magenta("Got it %d times"), aurora.Green(1240)))
}
Enable/Disable colors
package main
import (
"fmt"
"flag"
"github.com/logrusorgru/aurora/v4"
)
// colorizer
var au *aurora.Aurora
var colors = flag.Bool("colors", false, "enable or disable colors")
func init() {
flag.Parse()
au = aurora.New(WithColors(*colors))
}
func main() {
// use colorizer
fmt.Println(au.Green("Hello"))
}
Without flags:
With -colors
flag:
Hyperlinks, default colorizer, and configurations
Hyperlinks feature description.
Add a red hyperlinks with text "Example" that is referencing to http://example.com.
package main
import (
"flag"
"fmt"
"github.com/logrusorgru/aurora/v4"
)
func main() {
var conf = aurora.NewConfig()
conf.AddFlags(flag.CommandLine, "prefix.")
flag.Parse()
aurora.DefaultColorizer = aurora.New(conf.Options()...) // set global
fmt.Println(aurora.Red("Example").Hyperlink("http://example.com/"))
}
Depending flags:
Chains
The following samples are equal
x := aurora.BgMagenta(aurora.Bold(aurora.Red("x")))
x := aurora.Red("x").Bold().BgMagenta()
The second is more readable
Colorize
There is Colorize
function that allows to choose some colors and
format from a side
func getColors() Color {
// some stuff that returns appropriate colors and format
}
// [...]
func main() {
fmt.Println(aurora.Colorize("Greeting", getColors()))
}
Less complicated example
x := aurora.Colorize("Greeting", GreenFg|GrayBg|BoldFm)
Unlike other color functions and methods (such as Red/BgBlue etc)
a Colorize
clears previous colors
x := aurora.Red("x").Colorize(BgGreen) // will be with green background only
Grayscale
fmt.Println(" ",
aurora.Gray(1-1, " 00-23 ").BgGray(24-1),
aurora.Gray(4-1, " 03-19 ").BgGray(20-1),
aurora.Gray(8-1, " 07-15 ").BgGray(16-1),
aurora.Gray(12-1, " 11-11 ").BgGray(12-1),
aurora.Gray(16-1, " 15-07 ").BgGray(8-1),
aurora.Gray(20-1, " 19-03 ").BgGray(4-1),
aurora.Gray(24-1, " 23-00 ").BgGray(1-1),
)
8-bit colors
Methods Index
and BgIndex
implements 8-bit colors.
Index/BgIndex | Meaning | Foreground | Background |
---|---|---|---|
0- 7 | standard colors | 30- 37 | 40- 47 |
8- 15 | bright colors | 90- 97 | 100-107 |
16-231 | 216 colors | 38;5;n | 48;5;n |
232-255 | 24 grayscale | 38;5;n | 48;5;n |
Example
package main
import (
"fmt"
"github.com/logrusorgru/aurora"
)
func main() {
for i := uint8(16); i <= 231; i++ {
fmt.Println(i, aurora.Index(i, "pew-pew"), aurora.BgIndex(i, "pew-pew"))
}
}
Supported colors & formats
- formats
- bold (1)
- faint (2)
- doubly-underline (21)
- fraktur (20)
- italic (3)
- underline (4)
- slow blink (5)
- rapid blink (6)
- reverse video (7)
- conceal (8)
- crossed out (9)
- framed (51)
- encircled (52)
- overlined (53)
- background and foreground colors, including bright
- black
- red
- green
- yellow (brown)
- blue
- magenta
- cyan
- white
- 24 grayscale colors
- 216 8-bit colors
All colors
Standard and bright colors
Formats are likely supported
Formats are likely unsupported
Limitations
There is no way to represent %T
and %p
with colors using
a standard approach
package main
import (
"fmt"
"github.com/logrusorgru/aurora"
)
func main() {
var (
r = aurora.Red("red")
i int
)
fmt.Printf("%T %p\n", r, aurora.Green(&i))
}
Output will be without colors
aurora.value %!p(aurora.value={0xc42000a310 768 0})
The obvious workaround is Red(fmt.Sprintf("%T", some))
Windows
The Aurora provides ANSI colors only, so there is no support for Windows. That said, there are workarounds available. Check out these comments to learn more:
TTY
The Aurora has no internal TTY detectors by design. Take a look this comment if you want turn on colors for a terminal only, and turn them off for a file.
Licensing
Copyright © 2016-2022 The Aurora Authors. This work is free. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the the Unlicense. See the LICENSE file for more details.
*Note that all licence references and agreements mentioned in the aurora README section above
are relevant to that project's source code only.