package opam-core

  1. Overview
  2. Docs

Console output, ANSI color, logging and user querying

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

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

General text formatting

type 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.

val colorise : text_style -> string -> string

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

val colorise' : text_style list -> string -> string
val acolor : text_style -> Pervasives.out_channel -> string -> unit
val acolor_w : int -> text_style -> Pervasives.out_channel -> string -> unit

Logging

val timer : unit -> unit -> float

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

val log : string -> ?level:int -> ('a, Pervasives.out_channel, unit) Pervasives.format -> 'a

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

val slog : ('a -> string) -> Pervasives.out_channel -> '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

val error : ('a, unit, string, unit) Pervasives.format4 -> 'a
val warning : ('a, unit, string, unit) Pervasives.format4 -> 'a
val note : ('a, unit, string, unit) Pervasives.format4 -> 'a
val errmsg : ('a, Pervasives.out_channel, unit, unit, unit, unit) Pervasives.format6 -> 'a

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

val error_and_exit : ?num:int -> ('a, unit, string, 'b) Pervasives.format4 -> 'a
val msg : ('a, Pervasives.out_channel, unit, unit) Pervasives.format4 -> 'a
val formatted_msg : ?indent:int -> ('a, unit, string, unit) Pervasives.format4 -> 'a
val header_msg : ('a, unit, string, unit) Pervasives.format4 -> 'a
val header_error : ('a, unit, string, ('b, unit, string, unit) Pervasives.format4 -> 'b) Pervasives.format4 -> 'a
val status_line : ('a, unit, string, unit) Pervasives.format4 -> 'a

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

val confirm : ?default:bool -> ('a, unit, string, bool) Pervasives.format4 -> 'a

Ask the user to press Y/y/N/n to continue (returns a boolean). Defaults to true (yes) if unspecified

val read : ('a, unit, string, string option) Pervasives.format4 -> 'a

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

OCaml

Innovation. Community. Security.