text-utils is a collection of useful utilities for formatting text.
Add the following to your build.sbt:
libraryDependencies += "software.purpledragon" %% "text-utils" % "<version>"TableFormatter and SortedTableFormatter provide mechanisms for building and printing tabular data.
The simplest case is outputting a bare table without headers:
TableFormatter() .addRow("Apples", "25") .addRow("Pears", "10") .addRow("Bananas", "4") .print()Will output:
Apples 25 Pears 10 Bananas 4 Tables can also be sorted and have a header:
SortedTableFormatter("Produce", "Remaining") .addRow("Apples", "25") .addRow("Pears", "10") .addRow("Bananas", "4") .print()Will output:
| Produce | Remaining | ----------------------- | Apples | 25 | | Bananas | 4 | | Pears | 10 | Full details can be found in the documentation.