package opam-core

  1. Overview
  2. Docs

Module OpamConsoleSource

Console output, ANSI color, logging and user querying

Global configuration parameters (read from OpamGlobalConfig, and the environment when necessary)

Sourceval debug : unit -> bool
Sourceval verbose : unit -> bool
Sourceval color : unit -> bool
Sourceval utf8 : unit -> bool
Sourceval utf8_extended : unit -> bool
Sourceval disp_status_line : unit -> bool

General text formatting

Sourcetype text_style = [
  1. | `black
  2. | `blue
  3. | `bold
  4. | `crossed
  5. | `cyan
  6. | `green
  7. | `magenta
  8. | `red
  9. | `underline
  10. | `white
  11. | `yellow
]

Settable attributes for ANSI terminal output. Nesting is generally not handled.

Sourceval colorise : text_style -> string -> string

Helper coloring functions. Returns the string unchanged if color is disabled

Sourceval colorise' : text_style list -> string -> string
Sourceval acolor : text_style -> unit -> string -> string
Sourceval acolor_w : int -> text_style -> Format.formatter -> string -> unit
Sourcemodule Symbols : sig ... end
Sourceval utf8_symbol : Uchar.t -> ?alternates:Uchar.t list -> string -> string

Logging

Sourceval timer : unit -> unit -> float

Timers, only active when debug is on. Returns the time between the application to each argument, in seconds

Sourceval log : string -> ?level:int -> ('a, Format.formatter, unit) format -> 'a

log section ~level fmt args. Used for debug messages, default level is 1

Sourceval slog : ('a -> string) -> Format.formatter -> 'a -> unit

Helper to pass stringifiers to log (use log "%a" (slog to_string) x rather than log "%s" (to_string x) to avoid costly unneeded stringifications

Sourceval error : ('a, unit, string, unit) format4 -> 'a
Sourceval warning : ('a, unit, string, unit) format4 -> 'a
Sourceval note : ('a, unit, string, unit) format4 -> 'a
Sourceval errmsg : ('a, unit, string, unit) format4 -> 'a

Message without prefix, reformat or newline, to stderr (useful to continue error messages without repeating "ERROR")

Sourceval formatted_errmsg : ?indent:int -> ('a, unit, string, unit) format4 -> 'a
Sourceval error_and_exit : OpamStd.Sys.exit_reason -> ('a, unit, string, 'b) format4 -> 'a
Sourceval msg : ('a, unit, string, unit) format4 -> 'a
Sourceval formatted_msg : ?indent:int -> ('a, unit, string, unit) format4 -> 'a
Sourceval header_msg : ('a, unit, string, unit) format4 -> 'a
Sourceval header_error : ('a, unit, string, ('b, unit, string, unit) format4 -> 'b) format4 -> 'a
Sourceval carriage_delete : unit -> unit

Erase the current line on stdout (doesn't flush stdout)

Sourceval status_line : ('a, unit, string, unit) format4 -> 'a

Display a dynamic status line to stdout, that will be erased on next call. The message should not be wider than screen nor contain newlines. Use clear_status when the status line should be erased.

Sourceval clear_status : unit -> unit

Erase the status line and restore the cursor to the start of the line

Sourceval pause : ('a, unit, string, unit) format4 -> 'a

Show a prompt and wait for the user to press anything.

Sourceval confirm : ?require_unsafe_yes:bool -> ?default:bool -> ('a, unit, string, bool) format4 -> 'a

Ask the user to press Y/y/N/n to continue (returns a boolean). Defaults to true (yes) if unspecified. If require_unsafe_yes is true, it automatically answer yes to the question if automatic answering is set to `unsafe_yes ; otherwise it will prompt and wait user input if it is set `all_yes (interactive). Its default is false.

Sourceval menu : ?default:'a -> ?unsafe_yes:'a -> ?yes:'a -> no:'a -> options:('a * string) list -> ('b, unit, string, 'a) format4 -> 'b

Prompts the user with multiple numbered choices (answer, message).

unsafe_yes, yes are the options to choose if the corresponding global options are set. no is the option to choose otherwise, when non interactive, on escape. default is the option to choose on an active empty input ("\n"). Max 35 options.

Sourceval read : ('a, unit, string, string option) format4 -> 'a

Read some input from the user (returns a string option)

Sourceval print_table : ?cut:[ `Wrap of string | `Truncate | `None ] -> out_channel -> sep:string -> string list list -> unit

Prints a table; generally called on tables passed through align_table. The default cut is to wrap on stdout, stderr, keep as-is otherwise. `Wrap sep prepends sep on wrapped lines

Sourcemodule Tree : sig ... end

Tree printing

OCaml

Innovation. Community. Security.