package b0

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

Module B0_std_cliSource

Cmdliner support for more programs.

The cookbook blueprints has some examples.

Sourcemodule Exit : sig ... end

Program exits.

Miscellaneous argument converters

path is a converter for file system paths. No existence checks are performed on the path. Completes files and directories.

filepath is a converter for file paths. No existence checks are performed on the path. Completes files.

dirpath is a converter for directory paths. No existence checks are performed on the path. Completes directories.

cmd is a converter for commands which are parsed using B0_std.Cmd.of_string. Completes files.

ANSI text styling

Sourceval no_color : ?docs:string -> ?env:Cmdliner.Cmd.Env.info option -> unit -> bool Cmdliner.Term.t

no_color ~docs ~env () is a --no-color command line flag.

  • docs is the manual section in which the option is documented (defaults to Cmdliner.Manpage.s_common_options)
  • env is an environment variable to define the default value. It defaults to no_color_var which is NO_COLOR. The environment variable lookup performed by cmdliner for flags is tweaked to match what is requested by https://no-color.org.
Sourceval set_no_color : ?docs:Cmdliner.Manpage.section_name -> ?env:Cmdliner.Cmd.Env.info option -> unit -> unit Cmdliner.Term.t

set_no_color () behaves like no_color and sets B0_std.Fmt.styler to Plain when it's true. See an example.

Sourceval no_color_var : Cmdliner.Cmd.Env.info

no_color_var describes the default environment variable NO_COLOR of no_color and set_no_color.

Log level

log_level ~docs ~abset ~env () is a command line interface for specifying a log level with these options:

  • The --log-level=LEVEL option to specify the level directly.
  • The repeatable -v and --verbose flags specify the level as Info (one occurence) or Debug (two occurences).
  • The -q and --quiet flags take over all options and specify the level as Quiet.

The other arguments are:

Sourceval set_log_level : ?docs:Cmdliner.Manpage.section_name -> ?absent:B0_std.Log.level -> ?env:Cmdliner.Cmd.Env.info option -> unit -> unit Cmdliner.Term.t

set_log_level behaves like log_level and sets the log level. See an example.

Sourceval log_level_var : Cmdliner.Cmd.Env.info

log_level_var describes the default environment variable LOG_LEVEL of log_level and set_log_level.

log_level_conv is a converter for log level.

Specifying output level of details

Sourceval s_output_details_options : string

s_output_format_options is a manual section called "OUTPUT DETAILS OPTIONS"

Sourcetype output_details = [
  1. | `Short
    (*

    Short lined-based output with essential details.

    *)
  2. | `Normal
    (*

    Normal output.

    *)
  3. | `Long
    (*

    Long output with as much details as possible.

    *)
]

The type for specifying output level of details.

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

output_details () are mutually exclusive options to specify an output level of detail as `Short, `Normal or `Long.

  • Without options this is `Normal.
  • Options -s or --short specify `Short.
  • Options -l or --long specify `Long.

docs is the manual section in which options are documented, defaults to s_output_details_options.