diff --git a/dune-project b/dune-project index 1485c1a2..3381d7ef 100644 --- a/dune-project +++ b/dune-project @@ -16,7 +16,7 @@ astring (fmt (>= 0.8.9)) logs - cmdliner + (cmdliner (>= 1.1.0)) (tar-unix (>= 2.0.0)) yojson sexplib diff --git a/example.spec b/example.spec index 0fe8916d..3b0eb11e 100644 --- a/example.spec +++ b/example.spec @@ -7,11 +7,11 @@ ; The result can then be found in /tank/HASH/rootfs/ (where HASH is displayed at the end of the build). ((build dev - ((from ocaml/opam@sha256:af617095b1255a61f82ac1873031a850dd29c37865ff5bf691ab5ccd29187679) + ((from ocaml/opam@sha256:dca2be63c27c3860560bd70001f94c39c32e8a22fdc270e5e77d297b665c871f) (workdir /src) (user (uid 1000) (gid 1000)) ; Build as the "opam" user (run (shell "sudo chown opam /src")) - (env OPAM_HASH "b33a2146602d62541ce95e5f1f52b63827f076c2") ; Fix the version of opam-repository we want + (env OPAM_HASH "6ed2f3af9af5303f9a037a693e3f4696a4b51fe1") ; Fix the version of opam-repository we want (run (network host) (shell "sudo apt-get --allow-releaseinfo-change update")) diff --git a/lib/runc_sandbox.ml b/lib/runc_sandbox.ml index 0cb1b40e..1b54aca9 100644 --- a/lib/runc_sandbox.ml +++ b/lib/runc_sandbox.ml @@ -338,7 +338,7 @@ let fast_sync = Arg.value @@ Arg.flag @@ Arg.info - ~doc:"Ignore sync syscalls (requires runc >= 1.0.0-rc92)" + ~doc:"Ignore sync syscalls (requires runc >= 1.0.0-rc92)." ["fast-sync"] let cmdliner : config Term.t = diff --git a/main.ml b/main.ml index aaf7c97a..25c8c681 100644 --- a/main.ml +++ b/main.ml @@ -82,13 +82,14 @@ let setup_log style_renderer level = () let setup_log = - Term.(const setup_log $ Fmt_cli.style_renderer () $ Logs_cli.level ()) + let docs = Manpage.s_common_options in + Term.(const setup_log $ Fmt_cli.style_renderer ~docs () $ Logs_cli.level ~docs ()) let spec_file = Arg.required @@ Arg.opt Arg.(some file) None @@ Arg.info - ~doc:"Path of build spec file" + ~doc:"Path of build spec file." ~docv:"FILE" ["f"] @@ -96,7 +97,7 @@ let src_dir = Arg.required @@ Arg.pos 0 Arg.(some dir) None @@ Arg.info - ~doc:"Directory containing the source files" + ~doc:"Directory containing the source files." ~docv:"DIR" [] @@ -107,7 +108,7 @@ let store = Arg.required @@ Arg.opt Arg.(some store_t) None @@ Arg.info - ~doc:"btrfs:/path or rsync:/path or zfs:pool for build cache" + ~doc:"$(b,btrfs:/path) or $(b,rsync:/path) or $(b,zfs:pool) for build cache." ~docv:"STORE" ["store"] @@ -115,7 +116,7 @@ let id = Arg.required @@ Arg.pos 0 Arg.(some string) None @@ Arg.info - ~doc:"The ID of a build within the store" + ~doc:"The $(i,ID) of a build within the store." ~docv:"ID" [] @@ -123,45 +124,44 @@ let secrets = (Arg.value @@ Arg.(opt_all (pair ~sep:':' string file)) [] @@ Arg.info - ~doc:"Provide a secret under the form id:file" + ~doc:"Provide a secret under the form $(b,id:file)." ~docv:"SECRET" ["secret"]) let build = let doc = "Build a spec file." in - Term.(const build $ setup_log $ store $ spec_file $ Sandbox.cmdliner $ src_dir $ secrets), - Term.info "build" ~doc + let info = Cmd.info ~doc "build" in + Cmd.v info + Term.(const build $ setup_log $ store $ spec_file $ Sandbox.cmdliner $ src_dir $ secrets) let delete = let doc = "Recursively delete a cached build result." in - Term.(const delete $ setup_log $ store $ Sandbox.cmdliner $ id), - Term.info "delete" ~doc + let info = Cmd.info ~doc "delete" in + Cmd.v info + Term.(const delete $ setup_log $ store $ Sandbox.cmdliner $ id) let buildkit = Arg.value @@ Arg.flag @@ Arg.info - ~doc:"Output extended BuildKit syntax" + ~doc:"Output extended BuildKit syntax." ["buildkit"] let dockerfile = - let doc = "Convert a spec to Dockerfile format" in - Term.(const dockerfile $ setup_log $ buildkit $ spec_file), - Term.info "dockerfile" ~doc + let doc = "Convert a spec to Dockerfile format." in + let info = Cmd.info ~doc "dockerfile" in + Cmd.v info + Term.(const dockerfile $ setup_log $ buildkit $ spec_file) let healthcheck = - let doc = "Perform a self-test" in - Term.(const healthcheck $ setup_log $ store $ Sandbox.cmdliner), - Term.info "healthcheck" ~doc + let doc = "Perform a self-test." in + let info = Cmd.info ~doc "healthcheck" in + Cmd.v info + Term.(const healthcheck $ setup_log $ store $ Sandbox.cmdliner) let cmds = [build; delete; dockerfile; healthcheck] -let default_cmd = - let doc = "a command-line interface for OBuilder" in - Term.(ret (const (`Help (`Pager, None)))), - Term.info "obuilder" ~doc - -let term_exit (x : unit Term.result) = Term.exit x - let () = - term_exit @@ Term.eval_choice default_cmd cmds + let doc = "a command-line interface for OBuilder" in + let info = Cmd.info ~doc "obuilder" in + exit (Cmd.eval @@ Cmd.group info cmds) diff --git a/obuilder.opam b/obuilder.opam index 9a5fa2f3..b736cb51 100644 --- a/obuilder.opam +++ b/obuilder.opam @@ -14,7 +14,7 @@ depends: [ "astring" "fmt" {>= "0.8.9"} "logs" - "cmdliner" + "cmdliner" {>= "1.1.0"} "tar-unix" {>= "2.0.0"} "yojson" "sexplib" diff --git a/stress/stress.ml b/stress/stress.ml index 628f636d..ca797173 100644 --- a/stress/stress.ml +++ b/stress/stress.ml @@ -127,7 +127,7 @@ module Test(Store : S.STORE) = struct let ops = ops @ [Spec.run {|[ `cat output` = %S ] || exit 1|} expected] in let check_log data = data |> String.split_on_char '\n' |> List.filter_map (fun line -> - match Astring.String.cut ~sep:":" line with + match Astring.String.cut ~sep:":" line with | Some ("added", x) -> Some x | _ -> None ) @@ -221,8 +221,6 @@ let stress spec conf = open Cmdliner -let term_exit (x : unit Term.result) = Term.exit x - let store_t = Arg.conv Obuilder.Store_spec.(of_string, pp) @@ -236,11 +234,13 @@ let store = let cmd = let doc = "Run stress tests." in - Term.(const stress $ store $ Sandbox.cmdliner), - Term.info "stress" ~doc + let info = Cmd.info ~doc "stress" in + Cmd.v info + Term.(const stress $ store $ Sandbox.cmdliner) + let () = (* Logs.(set_level (Some Info)); *) Fmt_tty.setup_std_outputs (); Logs.set_reporter @@ Logs.format_reporter (); - term_exit @@ Term.eval cmd + exit @@ Cmd.eval cmd