Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gosuri/uitable
A go library to improve readability in terminal apps using tabular data
https://github.com/gosuri/uitable
Last synced: about 5 hours ago
JSON representation
A go library to improve readability in terminal apps using tabular data
- Host: GitHub
- URL: https://github.com/gosuri/uitable
- Owner: gosuri
- License: mit
- Created: 2015-11-13T21:59:21.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-10-18T07:02:33.000Z (about 2 years ago)
- Last Synced: 2024-12-05T03:46:13.734Z (7 days ago)
- Language: Go
- Homepage:
- Size: 27.3 KB
- Stars: 735
- Watchers: 15
- Forks: 32
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - uitable - Library to improve readability in terminal apps using tabular data. (Command Line / Advanced Console UIs)
- fucking-awesome-go - uitable - Library to improve readability in terminal apps using tabular data. (Command Line / Advanced Console UIs)
- awesome-go - uitable - Library to improve readability in terminal apps using tabular data. (Command Line / Advanced Console UIs)
- awesome-go - uitable - Library to improve readability in terminal apps using tabular data. (Command Line / Advanced Console UIs)
- awesome-go - uitable - A go library to improve readability in terminal apps using tabular data - ★ 451 (Command Line)
- awesome-go-extra - uitable - 11-13T21:59:21Z|2022-04-08T03:55:56Z| (Build Automation / Advanced Console UIs)
- awesome-go-with-stars - uitable - Library to improve readability in terminal apps using tabular data. (Command Line / Advanced Console UIs)
- awesome-go-cn - uitable
- awesome-go-plus - uitable - Library to improve readability in terminal apps using tabular data. ![stars](https://img.shields.io/badge/stars-735-blue) (Command Line / Advanced Console UIs)
- awesome-go-plus - uitable - Library to improve readability in terminal apps using tabular data. ![stars](https://img.shields.io/badge/stars-735-blue) (Command Line / Advanced Console UIs)
README
# uitable [![GoDoc](https://godoc.org/github.com/gosuri/uitable?status.svg)](https://godoc.org/github.com/gosuri/uitable) [![Build Status](https://travis-ci.org/gosuri/uitable.svg?branch=master)](https://travis-ci.org/gosuri/uitable)
uitable is a go library for representing data as tables for terminal applications. It provides primitives for sizing and wrapping columns to improve readability.
## Example Usage
Full source code for the example is available at [example/main.go](example/main.go)
```go
table := uitable.New()
table.MaxColWidth = 50table.AddRow("NAME", "BIRTHDAY", "BIO")
for _, hacker := range hackers {
table.AddRow(hacker.Name, hacker.Birthday, hacker.Bio)
}
fmt.Println(table)
```Will render the data as:
```sh
NAME BIRTHDAY BIO
Ada Lovelace December 10, 1815 Ada was a British mathematician and writer, chi...
Alan Turing June 23, 1912 Alan was a British pioneering computer scientis...
```For wrapping in two columns:
```go
table = uitable.New()
table.MaxColWidth = 80
table.Wrap = true // wrap columnsfor _, hacker := range hackers {
table.AddRow("Name:", hacker.Name)
table.AddRow("Birthday:", hacker.Birthday)
table.AddRow("Bio:", hacker.Bio)
table.AddRow("") // blank
}
fmt.Println(table)
```Will render the data as:
```
Name: Ada Lovelace
Birthday: December 10, 1815
Bio: Ada was a British mathematician and writer, chiefly known for her work on
Charles Babbage's early mechanical general-purpose computer, the Analytical
EngineName: Alan Turing
Birthday: June 23, 1912
Bio: Alan was a British pioneering computer scientist, mathematician, logician,
cryptanalyst and theoretical biologist
```## Installation
```
$ go get -v github.com/gosuri/uitable
```