···383383384384let main () =
385385 let doc = "Test manpage specifications" in
386386- let test_help =
387387- let doc = "Test manpage interactively as if --help[$(docv)] is invoked" in
388388- let help_fmts =
389389- ["auto", "=auto"; "pager", "=pager"; "groff", "=groff";
390390- "plain", "=plain"; "", ""]
386386+ let main =
387387+ let open Cmdliner.Term.Syntax in
388388+ let+ test_help =
389389+ let doc = "Test manpage interactively as if --help[$(docv)] is invoked" in
390390+ let help_fmts =
391391+ ["auto", "=auto"; "pager", "=pager"; "groff", "=groff";
392392+ "plain", "=plain"; "", ""]
393393+ in
394394+ let help_enum = Cmdliner.Arg.enum help_fmts and docv = "FMT" in
395395+ Arg.(value & opt ~vopt:(Some "") (some help_enum) None &
396396+ info ["test-help"] ~docv ~doc)
391397 in
392392- let help_enum = Cmdliner.Arg.enum help_fmts and docv = "FMT" in
393393- Arg.(value & opt ~vopt:(Some "") (some help_enum) None &
394394- info ["test-help"] ~docv ~doc)
398398+ fun () -> match test_help with
399399+ | None ->
400400+ Test.log "Invoke with %a[=FMT] to test %a[=FMT] interactively"
401401+ Fmt.code "--test-help" Fmt.code "--help";
402402+ Test.autorun ()
403403+ | Some fmt ->
404404+ Test.set_main_exit @@ fun () ->
405405+ let argv = Array.of_list (Cmd.name cmd :: ["--help" ^ fmt ]) in
406406+ Cmd.eval ~argv (Cmd.v info man_test_t)
395407 in
396396- Test.main' test_help ~doc @@ function
397397- | None ->
398398- Test.log "Invoke with %a[=FMT] to test %a[=FMT] interactively"
399399- Fmt.code "--test-help" Fmt.code "--help";
400400- Test.autorun ()
401401- | Some fmt ->
402402- Test.set_main_exit @@ fun () ->
403403- let argv = Array.of_list (Cmd.name cmd :: ["--help" ^ fmt ]) in
404404- Cmd.eval ~argv (Cmd.v info man_test_t)
408408+ Test.main' ~doc main
405409406410let () = if !Sys.interactive then () else exit (main ())