Skip to content

lsg551/tabula

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tabula

A rudimentary terminal table rendering library for Go using charmbracelet/lipgloss.


This library has been implemented for github.com/lsg551/matricula-online and its specific requirements. Although there are much better and more mature alternatives, most were missing a crucial feature I needed: Edge-to-edge layout or rendering tables that take up the full width of the terminal and have some columns that grow to fill the remaining space. You can see an example of this here.

Therefore, you should probably NOT use this library and one of the great alternatives instead, such as:

Installation

go get github.com/lsg551/tabula

Usage

import (
    "github.com/lsg551/tabula"
)

func main() {
	table := tabula.New([]tabula.Column{
		tabula.NewColumn("Name"),
		tabula.NewColumn("Age"),
		tabula.NewColumn("City"),
	})

	table.AddRow("Alice", "30", "London")
	table.AddRow("Bob", "25", "Berlin")

	println(table.String())
}

Calling table.String() or table.Render() will render the table as a string, which can be printed to the terminal. The above example will look like this:

==========================
  Name     Age    City    
==========================
  Alice    30     London  
  Bob      25     Berlin  

More examples can be found in the examples directory.

Documentation

Docs are available on pkg.go.dev.

License

This project is licensed under GPL-3.0 License.

About

Rudimentary table rendering library in Go for the terminal

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages