Skip to content

Instantly share code, notes, and snippets.

@hcarty
Last active June 16, 2016 16:41
Show Gist options
  • Save hcarty/52b8933a012611a26d7526d69bcf6dc4 to your computer and use it in GitHub Desktop.
Save hcarty/52b8933a012611a26d7526d69bcf6dc4 to your computer and use it in GitHub Desktop.
Example cmdliner terms
(* Cmdliner goodies *)
open Cmdliner
let make_config host sub accept respond =
{ My_library_sockets.host; sub; accept; respond }
let host =
let doc = "host IP address" in
let docv = "HOST" in
Arg.(value & opt string "127.0.0.1" & info ["h"; "host"] ~doc ~docv)
let sub =
let doc = "subscription port" in
let docv = "SUB" in
Arg.(value & opt int 5555 & info ["s"; "sub"] ~doc ~docv)
let accept =
let doc = "acceptance port" in
let docv = "ACCEPT" in
Arg.(value & opt int 5556 & info ["a"; "accept"] ~doc ~docv)
let respond =
let doc = "response port" in
let docv = "RESPOND" in
Arg.(value & opt int 5557 & info ["r"; "respond"] ~doc ~docv)
let config =
Term.(const make_config $ host $ sub $ accept $ respond)
val make_config : string -> int -> int -> int -> My_library_sockets.config
val host : string Cmdliner.Term.t
val sub : int Cmdliner.Term.t
val accept : int Cmdliner.Term.t
val respond : int Cmdliner.Term.t
val config : My_library_sockets.config Cmdliner.Term.t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment