package b0

  1. Overview
  2. Docs
Software construction and deployment kit

Install

dune-project
 Dependency

Authors

Maintainers

Sources

b0-0.0.6.tbz
sha512=e9aa779e66c08fc763019f16d4706f465d16c05d6400b58fbd0313317ef33ddea51952e2b058db28e65f7ddb7012f328c8bf02d8f1da17bb543348541a2587f0

doc/b0.std/B0_pager/index.html

Module B0_pagerSource

Pager interaction.

Paging

Sourcetype t

The type for pagers.

Sourceval does_page : t -> bool

does_page p is true iff p actually pages.

Sourceval find : ?search:B0_std.Cmd.tool_search -> ?cmd:B0_std.Cmd.t -> no_pager:bool -> unit -> (t, string) result

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

  1. Ok p if no_pager is true or if the TERM environment variable is dumb or undefined and cmd is unspecified. In this case does_page p is false.
  2. Ok p or Error _ if cmd is specified and according to whether Os.Cmd.get ?search cmd succeeds.
  3. Ok (Some pager) if pager is a tool invocation parsed from the PAGER environment variable that can be found via Os.Cmd.find ?search.
  4. Ok (Some pager) if either less or more can be found (in that order) via Os.Cmd.find ?search.
  5. Ok None otherwise.
Sourceval page_stdout : t -> (unit, string) result

page_stdout p setups the program so that if does_page p is true, the standard output of the program is redirected to a spawn of of the pager 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 does_page p is false this function has no effect.

Sourceval page_files : t -> B0_std.Fpath.t list -> (unit, string) result

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

  • false, each of the fs files is output on stdout, in order, separated by a file separator character (U+001C).
  • true, the pager's command is with fs as arguments, unless fs is empty in which case this is a nop.

Cli interaction

Sourcemodule Env : sig ... end

Environment variables.

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

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