GitHub Workflow

Escritoire

Escritoire is a simple library for printing tabular data in monospaced fonts, typically for use in console applications.

Features

  • prints data using Unicode box-drawing characters
  • supports multiline cells
  • cell contents may be left, right or centrally aligned
  • compact display for tables which don't include multiline contents

Availability

The current latest release of Escritoire is 0.4.0.

Getting Started

Creating a table to be displayed in a monospaced font (e.g. for rendering in a console) is easy, and first requires a Tabulation instance to be defined, specifying each column and how it should be rendered.

For example,

case class Person(name: String, age: Int, active: Boolean)

val table = Tabulation[Person](
  Column("Name", _.name),
  Column("Age", _.age),
  Column("Active", p => if p.active then "Yes" else "No")
)

describes a table of three columns, Name, Age and Active, defined for rows of type Person, where the content for each column is defined by a lambda, such as _.name and _.age. The return types of these lambdas are any types which can be rendered as AnsiStrings. In other words, any type for which an AnsiShow instance exists.

Given such a definition, any collection of instances of Person, ps, can be rendered as a table (a Seq[String] of each output line) of maximum width width by calling table.tabulate(width, ps).

For example,

val persons = List(Person("Bill", 48, true), Person("Janet", 54, false))
table.tabulate(100, persons)

will return a sequence of Strings which will print as,

┌───────┬─────┬────────┐
│ Name  │ Age │ Active │
├───────┼─────┼────────┤
│ Bill  │ 48  │ Yes    │
│ Janet │ 54  │ No     │
└───────┴─────┴────────┘

Related Projects

The following Scala One libraries are dependencies of Escritoire:

Escapade  

The following Scala One libraries are dependents of Escritoire:

Probably  

Status

Escritoire is classified as fledgling. Propensive defines the following five stability levels for open-source projects:

  • embryonic: for experimental or demonstrative purposes only, without any guarantees of longevity
  • fledgling: of proven utility, seeking contributions, but liable to significant redesigns
  • maturescent: major design decisions broady settled, seeking probatory adoption and refinement
  • dependable: production-ready, subject to controlled ongoing maintenance and enhancement; tagged as version 1.0 or later
  • adamantine: proven, reliable and production-ready, with no further breaking changes ever anticipated

Escritoire is designed to be small. Its entire source code currently consists of 200 lines of code.

Building

Escritoire can be built on Linux or Mac OS with Irk, by running the irk script in the root directory:

./irk

This script will download irk the first time it is run, start a daemon process, and run the build. Subsequent invocations will be near-instantaneous.

Contributing

Contributors to Escritoire are welcome and encouraged. New contributors may like to look for issues marked label: good first issue.

We suggest that all contributors read the Contributing Guide to make the process of contributing to Escritoire easier.

Please do not contact project maintainers privately with questions. While it can be tempting to repsond to such questions, private answers cannot be shared with a wider audience, and it can result in duplication of effort.

Author

Escritoire was designed and developed by Jon Pretty, and commercial support and training is available from Propensive OÜ.

Name

Escritoire is a pun: it is named after a type of writing table, since its purpose is for writing tables.

License

Escritoire is copyright © 2018-22 Jon Pretty & Propensive OÜ, and is made available under the Apache 2.0 License.