simpletable alternatives and similar packages
Based on the "Advanced Console UIs" category.
Alternatively, view simpletable 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 -
go-prompt
Building powerful interactive prompts in Go, inspired by python-prompt-toolkit. -
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. -
progressbar
A really basic thread-safe progress bar for Golang applications -
asciigraph
Go package to make lightweight ASCII line graph ╭┈╯ in command line apps with no other dependencies. -
uiprogress
A go library to render progress bars in terminal applications -
uilive
uilive is a go library for updating terminal output in realtime -
termenv
Advanced ANSI style & color support for your terminal applications -
aurora
Golang ultimate ANSI-colors that supports Printf/Sprintf methods -
uitable
A go library to improve readability in terminal apps using tabular data -
termtables
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命令补全脚本 -
tabular
Tabular simplifies printing ASCII tables from command line utilities -
marker
🖍️ Marker is the easiest way to match and mark strings for colorful terminal outputs! -
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
Access the most powerful time series database as a service
Do you think we are missing an alternative of simpletable or a related project?
README
Simple tables in terminal with Go
This package allows to generate and display ascii tables in the terminal, f.e.:
+----+------------------+--------------+-----------------------------+------+
| # | NAME | PHONE | EMAIL | QTTY |
+----+------------------+--------------+-----------------------------+------+
| 1 | Newton G. Goetz | 252-585-5166 | [email protected] | 10 |
| 2 | Rebecca R. Edney | 865-475-4171 | [email protected] | 12 |
| 3 | John R. Jackson | 810-325-1417 | [email protected] | 15 |
| 4 | Ron J. Gomes | 217-450-8568 | [email protected] | 25 |
| 5 | Penny R. Lewis | 870-794-1666 | [email protected] | 5 |
| 6 | Sofia J. Smith | 770-333-7379 | [email protected] | 3 |
| 7 | Karlene D. Owen | 231-242-4157 | [email protected] | 12 |
| 8 | Daniel L. Love | 978-210-4178 | [email protected] | 44 |
| 9 | Julie T. Dial | 719-966-5354 | [email protected] | 8 |
| 10 | Juan J. Kennedy | 908-910-8893 | [email protected] | 16 |
+----+------------------+--------------+-----------------------------+------+
| Subtotal | 150 |
+----+------------------+--------------+-----------------------------+------+
There are the following key features:
- Declarative style. Have to write more code, and hell with it.
- Styling. With 7 predefined styles: MySql-like (default), compact, compact lite, compact classic, markdown, rounded and unicode. And you can change it.
- Header and footer. Separated from table body.
- Multiline cells support. See _example/main.go/_example/04-multiline/main.go for example.
- Cell content alignment. Left, right or center.
- Row spanning. By analogy with the way it is done in HTML. See
Cell.Span
attribute description. - Fast! Really fast, see _example/main.go/_example/03-benchmarks-with-others.
Installation
$ go get -u github.com/alexeyco/simpletable
To run unit tests:
$ cd $GOPATH/src/github.com/alexeyco/simpletable
$ go test -cover
To run benchmarks:
$ cd $GOPATH/src/github.com/alexeyco/simpletable
$ go test -bench=.
Comparison with similar libraries see _example/main.go/_example/03-benchmarks-with-others
Basic example
package main
import (
"fmt"
"github.com/alexeyco/simpletable"
)
var (
data = [][]interface{}{
{1, "Newton G. Goetz", 532.7},
{2, "Rebecca R. Edney", 1423.25},
{3, "John R. Jackson", 7526.12},
{4, "Ron J. Gomes", 123.84},
{5, "Penny R. Lewis", 3221.11},
}
)
func main() {
table := simpletable.New()
table.Header = &simpletable.Header{
Cells: []*simpletable.Cell{
{Align: simpletable.AlignCenter, Text: "#"},
{Align: simpletable.AlignCenter, Text: "NAME"},
{Align: simpletable.AlignCenter, Text: "TAX"},
},
}
subtotal := float64(0)
for _, row := range data {
r := []*simpletable.Cell{
{Align: simpletable.AlignRight, Text: fmt.Sprintf("%d", row[0].(int))},
{Text: row[1].(string)},
{Align: simpletable.AlignRight, Text: fmt.Sprintf("$ %.2f", row[2].(float64))},
}
table.Body.Cells = append(table.Body.Cells, r)
subtotal += row[2].(float64)
}
table.Footer = &simpletable.Footer{
Cells: []*simpletable.Cell{
{},
{Align: simpletable.AlignRight, Text: "Subtotal"},
{Align: simpletable.AlignRight, Text: fmt.Sprintf("$ %.2f", subtotal)},
},
}
table.SetStyle(simpletable.StyleCompactLite)
fmt.Println(table.String())
}
Result:
# NAME TAX
--- ------------------ ------------
1 Newton G. Goetz $ 532.70
2 Rebecca R. Edney $ 1423.25
3 John R. Jackson $ 7526.12
4 Ron J. Gomes $ 123.84
5 Penny R. Lewis $ 3221.11
--- ------------------ ------------
Subtotal $ 12827.02
You can see also _example/main.go/01-styles-demo/main.go for styles demonstration.
$ cd $GOPATH/src/github.com/alexeyco/simpletable/_example/01-styles-demo
$ go run main.go
More examples: For more examples see _example directory:
$ cd $GOPATH/src/github.com/alexeyco/simpletable/_example
$ ls -F | grep /
01-styles-demo/
02-ugly-span/
03-benchmarks-with-others/
04-multiline/
Styling
There is 6 styles available. To view them, run _example/main.go/01-styles-demo/main.go:
$ cd $GOPATH/src/github.com/alexeyco/simpletable/_example/01-styles-demo
$ go run main.go
Cell content alignment
You can set cell content alignment:
c := &simpletable.Cell{
// or simpletable.AlignLeft (default), or simpletable.AlignCenter
Align: simpletable.AlignRight,
Content: "Subtotal",
}
Column spanning
By analogy with HTML:
c := &simpletable.Cell{
Span: 2, // Default: 1
Content: "Subtotal",
}
Note: by default Span
is 1
. If you try to set it to 0
, the value will still be 1
.
License
Copyright (c) 2017 Alexey Popov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*Note that all licence references and agreements mentioned in the simpletable README section above
are relevant to that project's source code only.