Module More_cli

Cmdliner support for more programs.

The cookbook blueprints has some examples.

module Exit : sig ... end

Program exits.

Miscellaneous argument converters

val path : More.Fpath.t Cmdliner.Arg.conv

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

val filepath : More.Fpath.t Cmdliner.Arg.conv

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

val dirpath : More.Fpath.t Cmdliner.Arg.conv

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

val cmd : More.Cmd.t Cmdliner.Arg.conv

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

ANSI text styling

val 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.
val 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 More.Fmt.styler to Plain when it's true. See an example.

val 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

val log_level : ?docs:Cmdliner.Manpage.section_name -> ?absent:More.Log.level -> ?env:Cmdliner.Cmd.Env.info option -> unit -> More.Log.level Cmdliner.Term.t

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:

  • docs is the manual section in which the options are documented (defaults to Cmdliner.Manpage.s_common_options)
  • absent is the level when none is specified it defaults to More.Log.level.Warning
  • env is an environment variable to define the default level value. It defaults to log_level_var which is LOG_LEVEL.
val set_log_level : ?docs:Cmdliner.Manpage.section_name -> ?absent:More.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.

val log_level_var : Cmdliner.Cmd.Env.info

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

val log_level_conv : More.Log.level Cmdliner.Arg.Conv.t

log_level_conv is a converter for log level.

Specifying output level of details

val s_output_details_options : string

s_output_format_options is a manual section called "OUTPUT DETAILS OPTIONS"

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

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