package b0

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Pager interaction.

Environment variables

module Env : sig ... end

Environment variables.

val envs : unit -> Cmdliner.Cmd.Env.info list

envs () describe the PAGER and TERM environment variable for cmdliner.

Paging

val find : ?win_exe:bool -> ?search:B0_std.Fpath.t list -> don't:bool -> unit -> (B0_std.Cmd.t option, string) result

find ~search ~don't finds a suitable pager. This is (in order):

  1. Ok None if don't is true or if the TERM environment variable is dumb or undefined.
  2. Ok (Some pager) if pager is a tool invocation parsed from the PAGER environment variable that can be found via Os.Cmd.find_tool ?win_exe ?search.
  3. Ok (Some pager) if either less or more can be found (in that order) via Os.Cmd.find_tool ?win_exe ?search.
  4. Ok None otherwise.
val page_stdout : B0_std.Cmd.t option -> (unit, string) result

page_stdout pager setups the program so that if pager is Some cmd, the standard output of the program is redirected to a spawn of cmd with the following twists:

  • If the environment variable LESS is undefined in the current environment it is set to LESS=FRX for the spawn of cmd.
  • A Stdlib.at_exit function is installed that flushes B0_std.Fmt.stdout and Stdlib.stdout, closes Unix.stdout and waits upon the cmd spawn termination.

If pager is None this function has no effect.

val page_files : B0_std.Cmd.t option -> B0_std.Fpath.t list -> (unit, string) result

page_files pager fs uses pager to page the files fs. If pager is:

  • None, each of the fs files is output on stdout in order separated by a file separator character (U+001C).
  • Some cmd, cmd is run with fs as arguments. If fs is empty does nothing.

Cli interaction

val don't : ?docs:string -> unit -> bool Cmdliner.Term.t

don't ~docs () is a --no-pager command line option to unconditionally request not use a pager. docs is the manual section where the option is documented, defaults to Cmdliner.Manpage.s_common_options.

OCaml

Innovation. Community. Security.