Module B0_ui.Pager
Pager interaction.
Cli arguments
val envs : Cmdliner.Term.env_info list
envs
describe thePAGER
andTERM
environment variable.
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.
Pager
val find : ?search:B0_std.Fpath.t list -> don't:bool -> unit -> (B0_std.Cmd.t option, string) Stdlib.result
find ~search ~don't
finds a suitable pager. This is (in order):Ok None
ifdon't
istrue
or if theTERM
environment variable isdumb
or undefined.Ok (Some pager)
ifpager
is a tool invocation parsed from thePAGER
environment variable that can be found viaOs.Cmd.find ?search
.Ok (Some pager)
if eitherless
ormore
can be found (in that order) viaOs.Cmd.find ?search
.Ok None
otherwise.
val page_stdout : B0_std.Cmd.t option -> (unit, string) Stdlib.result
page_stdout pager
setups the program so that ifpager
isSome cmd
, the standard output of the program is redirected to a spawn ofcmd
with the following twists:- If the environment variable
LESS
is undefined in the current environment it is set toLESS=FRX
for the spawn ofcmd
. - A
Pervasive
.at_exit function is installed that flushesFmt
.stdout andstdout
, closesUnix.stdout
and waits upon thecmd
spawn termination.
If
pager
isNone
this function has no effect.- If the environment variable
val page_files : B0_std.Cmd.t option -> B0_std.Fpath.t list -> (unit, string) Stdlib.result
page_files pager fs
usespager
to page the filesfs
. Ifpager
is:None
, each of thefs
files is output on stdout in order separated by a file separator character (U+001C).Some cmd
,cmd
is run withfs
as arguments. Iffs
is empty does nothing.