package cmdliner-stdlib

  1. Overview
  2. Docs
A collection of cmdliner terms to control OCaml runtime parameters

Install

Dune Dependency

Authors

Maintainers

Sources

cmdliner-stdlib-1.0.0.tbz
sha256=5e8986fd8d86a6df0e5031e58ac2dafd738c41767ce4ca08059659246ce8313a
sha512=c693e60d79f0977122afad7b5dc1a273db692985c47b40d9a47372b3c3fbbfbce1a33d5808dcd0df21c45b4341d993c145e0033716cf07dfd20dd2ad5ba21d8f

README.md.html

cmdliner-stdlib

The cmdliner-stdlib package is a collection of cmdliner terms that help control OCaml runtime parameters, usually configured through the OCAMLRUNPARAM environment variable. The package provides command-line options for controlling features like backtrace, hash table randomization, and garbage collector tuning.

Installation

You can install the package using opam:

opam install cmdliner-stdlib

Usage

You can use these command-line arguments to:

  • enable/disable backtraces;

  • enable/disable table randomization, for better security and prevent collision attacks; and

  • control the OCaml garbage collector as described in detail in the GC control documentation.

open Cmdliner

let cmd = Cmd.v (Cmd.info "hello") (Cmdliner_stdlib.setup ())
let () = exit (Cmd.eval cmd)

You can then use command-line options to change parameters of the OCaml runtime. For instance, to enable backtraces and change the GC allocation policy to "first fit":

$ dune exec -- ./hello.exe --allocation-policy=first-fit --backtrace=true

You can disable some of these arguments. For instance, to disable GC control use:

   Cmdliner_stdlib.setup ~gc_control:None ()

Or to change the default allocation policy to be first-fit:

  let default = Gc.get () in
  let gc_control = Some { default with allocation_policy = 1 } in
  Cmdliner_stdlib.setup ~gc_control ()

Contributions

We welcome contributions, bug reports, and feature requests. Please visit our GitHub repository for more information.

OCaml

Innovation. Community. Security.