https://github.com/aziontech/tablecli
A command-line tool for generating and managing tables.
https://github.com/aziontech/tablecli
Last synced: 7 months ago
JSON representation
A command-line tool for generating and managing tables.
- Host: GitHub
- URL: https://github.com/aziontech/tablecli
- Owner: aziontech
- License: mit
- Created: 2024-05-02T19:41:17.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-25T12:20:25.000Z (over 1 year ago)
- Last Synced: 2025-10-24T13:58:05.825Z (8 months ago)
- Language: Go
- Homepage: https://www.azion.com
- Size: 263 KB
- Stars: 2
- Watchers: 6
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# tablecli
[](https://opensource.org/licenses/MIT)
[](https://godoc.org/github.com/aziontech/tablecli)
[](https://goreportcard.com/report/github.com/aziontech/tablecli)
This package provides a convenient way to generate tabular output of any data, which is useful primarily for CLI tools.

#### Install Package
```sh
go get github.com/aziontech/tablecli
```
#### Example of use:
```go
package main
import (
table "github.com/aziontech/tablecli"
"github.com/fatih/color"
"strings"
)
type list struct {
ID string
Name string
}
func main() {
tbl := table.New("ID", "NAME")
headerFmt := color.New(color.FgBlue, color.Underline).SprintfFunc()
columnFmt := color.New(color.FgGreen).SprintfFunc()
tbl.WithHeaderFormatter(headerFmt).WithFirstColumnFormatter(columnFmt)
var list = []list{
{ "123123", "Jonh"},
{ "123121", "Jeff"},
}
for _, i := range list {
tbl.AddRow(i.ID, i.Name)
}
format := strings.Repeat("%s", len(tbl.GetHeader())) + "\n"
tbl.CalculateWidths([]string{})
tbl.PrintHeader(format)
for _, r := range tbl.GetRows() {
tbl.PrintRow(format, r)
}
}
```
#### Output:
```sh
ID NAME
123123 Jonh
123121 Jeff
```
## License
This project is licensed under the terms of the [MIT](LICENSE) license.