package console

All checked builds pass
  1. Overview
  2. Docs
Colours, tables, trees and progress rows for the terminal

Install

dune-project
 Dependency

Authors

Maintainers

Sources

console-0.9.0.tbz
sha256=1c6851dbc38514bf717da9bbe9cddda3c2958b215f934dee69324f1ec243873f
sha512=71bd51d2cbaf945ae153e863c2de189b32f3049c750131cc32e96e43759e4d8b62f9bf8863ff2e80429d56d32209573b85d3da9e0d67ad52bb1106b4c763070f

doc/index.html

console

Colours, tables, trees and progress rows for OCaml command-line tools.

console prints into the terminal's normal scrollback and, while work runs, redraws only the progress rows of a Console.Display.

Its widgets lay out text in a style and print with Fmt, in the colours and the Console.Theme of the formatter that prints them, or as plain text on a pipe:

# let sizes =
    Console.Table.(
      view
        [
          column (Console.View.text "Package");
          column ~align:`Right (Console.View.text "Size");
        ]
        [
          [ Console.View.text "console"; Console.View.text "42 KiB" ];
          [ Console.View.text "console-eio"; Console.View.text "9 KiB" ];
        ]);;
val sizes : Console.View.t = <abstr>
# Fmt.pr "%a@." Console.View.pp sizes;;
╭─────────────┬────────╮
│ Package     │   Size │
├─────────────┼────────┤
│ console     │ 42 KiB │
│ console-eio │  9 KiB │
╰─────────────┴────────╯
- : unit = ()

Manuals

  • Widgets and themes shows the widgets with the text they print, and how the themes draw them.
  • The console-eio package runs the progress rows with Eio. Its documentation opens with a tutorial, A first CLI, which builds a whole command step by step, with options for colour and theme, a table, progress rows and a test of its output.

Libraries

The console package has four libraries:

  • console, the module Console: styles, views, the widgets, the themes, tasks, the live Console.Display and how tasks show on it, Console.Progress. It needs neither Eio nor Unix.
  • console.tty, the module Console_tty: colour, colour depth and UTF-8 for the standard outputs, decided from the terminal and the environment or from a --color option.
  • console.text, the module Console_text: untrusted text made safe to print, without the rest of console.
  • console.input, the module Console_input: a line editor that turns the bytes typed into echo and lines, and does no input or output itself.

Where to start