Skip to content

Instantly share code, notes, and snippets.

@yawaramin
Last active January 21, 2017 06:16
Show Gist options
  • Save yawaramin/7abed718bd77056b940a8b0415c8b43e to your computer and use it in GitHub Desktop.
Save yawaramin/7abed718bd77056b940a8b0415c8b43e to your computer and use it in GitHub Desktop.
open Cmdliner
let mycli _ _ = print_endline "Success!"
let interface =
let docv = "INTERFACE" in
let doc = "parse AST as an interface (true or false)" in
Arg.(required & pos 0 (some bool) None & info ~docv ~doc [])
let recoverable =
let docv = "RECOVERABLE" in
let doc = "enable recoverable parser (true or false)" in
Arg.(required & pos 1 (some bool) None & info ~docv ~doc [])
let mycli_t = Term.(const mycli $ interface $ recoverable)
let top_level_info =
let doc = "My simple CLI utility" in
let man =
[ `S "DESCRIPTION";
`P "mycli is a tiny utility to understand Cmdliner" ] in
Term.info "mycli" ~doc ~man
let () =
match Term.eval (mycli_t, top_level_info) with
| `Error _ -> exit 1 | _ -> ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment