Skip to content

Instantly share code, notes, and snippets.

@mjambon
Last active December 7, 2019 02:55
Show Gist options
  • Save mjambon/1122b2e335a63a724fabeb464615d775 to your computer and use it in GitHub Desktop.
Save mjambon/1122b2e335a63a724fabeb464615d775 to your computer and use it in GitHub Desktop.
That feeling when you realize there's no magic in Cmdliner
(*
Sample command-line argument specified using Cmdliner's author's style.
*)
open Cmdliner
let seed_term =
let doc = "
Use the number $(docv) to initialize the global pseudo-random number
generator.
"
in
Arg.(value & opt (some int) None & info ["seed"] ~docv:"SEED" ~doc)
(*
Same command-line argument specification rewritten using a plain style.
*)
open Cmdliner
let seed_term =
let doc = "
Use the number $(docv) to initialize the global pseudo-random number
generator.
"
in
let info = Arg.info ["seed"] ~docv:"SEED" ~doc in
let arg = Arg.opt (Arg.some Arg.int) None info in
Arg.value arg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment