Display contents as a grid in the terminal!
Format unidimensional lists (slices) as grids, with well-defined columns, suitable for fixed-width fonts, for the sake of readability.
It's both a CLI and a Go library.
Inspired by ogham/rust-term-grid and by the fact that I needed it for paemuri/ipe.
What we do not want:
What we want:
brew tap paemuri/packages
brew install gridt
go install github.com/paemuri/gridt/cmd/gridt
Runs the program with default configuration. It gets the values from stdin lines.
Shows the CLI help message.
Shows the CLI version.
Instead of getting the lines from stdin, gets it from a specific file.
Defines what separates every value column. Defaults to " "
.
Defines writing direction. It can be top-to-bottom
or left-to-right
.
Defaults to top-to-bottom
.
// Just create an empty grid...
grid := gridt.New(gridt.TopToBottom, " ")
// Verify if it fits in a determined width...
dim, ok := grid.FitIntoWidth(100)
// And get its string!
if ok {
fmt.Print(dim.String())
}
// But also, you can do a lot more!
// Create a grid with pre-defined cells...
grid := gridt.New(gridt.LeftToRight, " ", "cell1", "cell2", "cell3")
// Manipulate the cells...
grid.Add("cell4", "cell5", "cell6")
grid.Insert(2, "cell2.1", "cell2.3")
grid.Delete(0)
// Base the size of the grid on the number of columns,
// instead of the number of caracters...
dim, ok := grid.FitIntoColumns(3)
This project code is in the public domain. See the LICENSE file.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be in the public domain, without any additional terms or conditions.