package console

Build not yet checked
  1. Overview
  2. Docs
Colours, tables, trees and progress rows for the terminal

Install

dune-project
 Dependency

Authors

Maintainers

Sources

console-0.10.1.tbz
sha256=37ad65f6833c65814b0673f009f6b656c5194608ca03519da2e63e1051d54f6e
sha512=7677067f1a3244779cdbc5c90a8b0e1eba30c3fd58281584ea3d4c46c3e219eef0668588ca0e2938799c61a3fa831ce2146eac73717214d7baf96b497bfcd892

doc/console.cli/Console_cli/index.html

Module Console_cliSource

Command-line options for the look of a program's output.

setup adds --color and --theme options to a Cmdliner program. It applies them to both standard outputs and sets the program's theme. The progress rows on standard error, the text on standard output and the strings built with Fmt.str all use them:

let main () =
  Fmt.pr "%a@." Console.View.pp
    (Console.Panel.view (Console.View.text "hello"))

let cmd =
  Cmdliner.Cmd.v
    (Cmdliner.Cmd.info "hello")
    Cmdliner.Term.(const main $ Console_cli.setup ())

This library is console.cli. It needs Cmdliner and Unix.

Sourceval setup : ?docs:string -> unit -> unit Cmdliner.Term.t

setup () is a term that reads two options and passes them to Console_tty.setup ?style_renderer ?theme ():

  • --color=auto|always|never, read by Fmt_cli.style_renderer;
  • --theme=NAME, where NAME is a name in Console.Theme.all.

Without --color, the environment decides colour. Without --theme, the program's theme (Console.Theme.program) does not change. The manual lists the options in the section docs (defaults to Cmdliner.Manpage.s_common_options). Do not also use Fmt_cli.style_renderer: it defines the same --color option.