t2
Utility for text tables.
Getting Started
Add t2 as a dependency to your project:
libraryDependencies += "com.github.losizm" %% "t2" % "0.4.1"
Usage
Below is an example of t2 in action. Here it builds a table and writes the content to stdout.
// Build table with first row as table header
val table = t2.TableBuilder()
.add("#", "Effective Date", "Currency Code", "Exchange Rate")
.add("1", "2021-01-04", "USD", "0.690236")
.add("2", "2021-01-05", "USD", "0.690627")
.add("3", "2021-01-06", "USD", "0.689332")
.build()
// Create table writer with supplied configuration
val writer = t2.TableWriter(
"ansiColorEnabled" -> "true",
"tableBorderColor" -> "cyan",
"tableHeaderColor" -> "black,yellowBackground",
"bodyRuleColor" -> "yellow",
"rowHeaderEnabled" -> "true",
"rowHeaderColor" -> "bold,cyan",
"columnRightAlign" -> "0,3" // Right align first and last columns
)
// Write table to stdout
writer.write(System.out, table)
The generated output would look something like the following if printed to a color-enabled terminal.
Table output can be restyled using configuration for such things as changing cell padding, character used for table borders, and more.
API Documentation
See scaladoc for additional details.
License
t2 is licensed under the Apache License, Version 2. See LICENSE file for more information.