package batteries

  1. Overview
  2. No Docs
A community-maintained standard library extension

Install

Dune Dependency

Authors

Maintainers

Sources

v3.7.1.tar.gz
md5=d02c4f044e53edca010de46f9139ce00
sha512=99a5afa3604c4cf0c849c670111d617f7f255acb0da043b73ddffdf0e299948bce52516ee31921f269de6088156c4e0a187e0b931543c6819c6b25966b303281

doc/batteries.unthreaded/BatOptParse/StdOpt/index.html

Module BatOptParse.StdOptSource

This module contains various standard options.

Flag options
Sourceval store_const : ?default:'a -> 'a -> 'a Opt.t

store_const ?default const returns a flag option which stores the constant value const when the option is encountered on the command line.

Sourceval store_true : unit -> bool Opt.t

store_true () returns an option which is set to true when it is encountered on the command line. The default value is false.

Sourceval store_false : unit -> bool Opt.t

store_false () returns an option which is set to false when it is encountered on the command line. The default value is true.

Sourceval count_option : ?dest:int ref -> ?increment:int -> unit -> int Opt.t

Create a counting option which increments its value each time the option is encountered on the command line.

  • parameter increment

    Increment to add to the option value each time the option is encountered.

  • parameter dest

    Reference to the option value. Useful for making options like '--quiet' and '--verbose' sharing a single value.

  • returns

    the newly created option.

Sourceval incr_option : ?dest:int ref -> unit -> int Opt.t

Exactly identical to count_option ~dest:dest ~increment:1 ().

Sourceval decr_option : ?dest:int ref -> unit -> int Opt.t

Exactly identical to count_option ~dest:dest ~increment:(-1) ().

Value options
Sourceval int_option : ?default:int -> ?metavar:string -> unit -> int Opt.t

int_option ?default ?metavar () returns an option which takes a single integer argument. If ~default is given it is the default value returned when the option has not been encountered on the command line.

Sourceval float_option : ?default:float -> ?metavar:string -> unit -> float Opt.t

See OptParse.StdOpt.int_option.

Sourceval str_option : ?default:string -> ?metavar:string -> unit -> string Opt.t

See OptParse.StdOpt.int_option.

Sourceval any_option : ?default:'a option -> ?metavar:string -> (string -> 'a) -> 'a Opt.t

any_option ?default ?metavar coerce returns an option which takes a single argument from the command line and calls coerce to coerce it to the proper type.

default is the default value of the option. If None, the option has no default value.

Callback options
Sourceval int_callback : ?metavar:string -> (int -> unit) -> unit Opt.t

int_callback ?metavar f returns an option which takes a single integer argument and calls f with that argument when encountered on the command line.

Sourceval float_callback : ?metavar:string -> (float -> unit) -> unit Opt.t

See OptParse.StdOpt.int_callback.

Sourceval str_callback : ?metavar:string -> (string -> unit) -> unit Opt.t

See OptParse.StdOpt.int_callback.

Special options
Sourceval help_option : unit -> 'a Opt.t

help_option () returns the standard help option which displays a usage message and exits the program when encountered on the command line.

Sourceval version_option : (unit -> string) -> 'a Opt.t

version_option f returns the standard version option which displays the string returned by f () (and nothing else) on standard output and exits.

OCaml

Innovation. Community. Security.