miou-solo5/test/cmdline.ml

31 lines
712 B
OCaml
Raw Normal View History

2024-12-08 16:00:01 +00:00
let run foo bar =
Miou_solo5.(run []) @@ fun () ->
let argv = Array.to_list Sys.argv in
Fmt.pr "%s\n%!" (String.concat " " argv);
Fmt.pr "foo: %a\n%!" Fmt.(Dump.option (fmt "%S")) foo;
Fmt.pr "bar: %a\n%!" Fmt.(Dump.option (fmt "%S")) bar
open Cmdliner
let foo =
let doc = "Foo" in
let open Arg in
value & opt (some string) None & info [ "foo" ] ~doc
let bar =
let doc = "Bar" in
let open Arg in
value & opt (some string) None & info [ "bar" ] ~doc
let term =
let open Term in
const run $ foo $ bar
let cmd =
let doc = "A simple unikernel to test the command-line." in
let man = [] in
let info = Cmd.info "cmd" ~doc ~man in
Cmd.v info term
let () = Cmd.(exit @@ eval cmd)