Skip to content

stringbean/text-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Codacy Grade Maven Central - Scala 2.12 Maven Central - Scala 2.13 Maven Central - Scala 3

Simple Text Utils for Scala

text-utils is a collection of useful utilities for formatting text.

Quickstart

Add the following to your build.sbt:

libraryDependencies += "software.purpledragon" %% "text-utils" % "<version>"

Table Formatting

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.