diff --git a/bin/check.ml b/bin/check.ml index 1558d88f..a28a65fd 100644 --- a/bin/check.ml +++ b/bin/check.ml @@ -14,10 +14,6 @@ let clone_and_checkout_tag repo ~dir ~tag = open Cmdliner -let working_tree = - let doc = "Perform the check on the current working tree." in - Arg.(value & flag & info [ "working-tree" ] ~doc) - let doc = "Check dune-release compatibility" let man = @@ -44,7 +40,10 @@ let term = and+ skip_build = Cli.skip_build and+ skip_tests = Cli.skip_tests and+ skip_change_log = Cli.skip_change_log - and+ on_working_tree = working_tree in + and+ on_working_tree = + let doc = "Perform the check on the current working tree." in + Arg.(value & flag & info [ "working-tree" ] ~doc) + in (let dir, clean_up = if on_working_tree then (OS.Dir.current (), fun _ -> ()) else diff --git a/bin/cli.ml b/bin/cli.ml index b52dec4f..b8c60df0 100644 --- a/bin/cli.ml +++ b/bin/cli.ml @@ -245,28 +245,23 @@ let keep_build_dir = (* use cmdliner evaluation error *) let setup = - let style_renderer = - let env = Cmd.Env.info "DUNE_RELEASE_COLOR" in - Fmt_cli.style_renderer ~docs:Manpage.s_common_options ~env () - in - let log_level = - let env = Cmd.Env.info "DUNE_RELEASE_VERBOSITY" in - Logs_cli.level ~docs:Manpage.s_common_options ~env () - in - let cwd = - let doc = "Change to directory $(docv) before doing anything." in - let docv = "DIR" in - Arg.( - value - & opt (some path_arg) None - & info [ "C"; "pkg-dir" ] ~docs:Manpage.s_common_options ~doc ~docv) - in Term.( ret (let open Syntax in - let+ style_renderer = style_renderer - and+ log_level = log_level - and+ cwd = cwd in + let+ style_renderer = + let env = Cmd.Env.info "DUNE_RELEASE_COLOR" in + Fmt_cli.style_renderer ~docs:Manpage.s_common_options ~env () + and+ log_level = + let env = Cmd.Env.info "DUNE_RELEASE_VERBOSITY" in + Logs_cli.level ~docs:Manpage.s_common_options ~env () + and+ cwd = + let doc = "Change to directory $(docv) before doing anything." in + let docv = "DIR" in + Arg.( + value + & opt (some path_arg) None + & info [ "C"; "pkg-dir" ] ~docs:Manpage.s_common_options ~doc ~docv) + in Fmt_tty.setup_std_outputs ?style_renderer (); Logs.set_level log_level; Logs.set_reporter (Logs_fmt.reporter ~app:Fmt.stdout ()); diff --git a/bin/config.ml b/bin/config.ml index 3b8dd48c..9d3468a2 100644 --- a/bin/config.ml +++ b/bin/config.ml @@ -141,31 +141,28 @@ let man = newly created opam-repository PR or not."; ] -let action = - let docv = "ACTION" in - let doc = - "The action to perform, either $(b,show) the config or $(b,set) a config \ - field" - in - Cmdliner.Arg.(value & pos 0 string "show" & info ~doc ~docv []) - -let key = - let docv = "KEY" in - let doc = - "The configuration field to set or print. For $(b,show), if no key is \ - provided, the entire config will be printed." - in - Cmdliner.Arg.(value & pos 1 (some string) None & info ~doc ~docv []) - -let value = - let docv = "VALUE" in - let doc = "The new field value" in - Cmdliner.Arg.(value & pos 2 (some string) None & info ~doc ~docv []) - let term = Cmdliner.Term.( let open Syntax in - let+ action = action and+ key_opt = key and+ value_opt = value in + let+ action = + let docv = "ACTION" in + let doc = + "The action to perform, either $(b,show) the config or $(b,set) a \ + config field" + in + Cmdliner.Arg.(value & pos 0 string "show" & info ~doc ~docv []) + and+ key_opt = + let docv = "KEY" in + let doc = + "The configuration field to set or print. For $(b,show), if no key is \ + provided, the entire config will be printed." + in + Cmdliner.Arg.(value & pos 1 (some string) None & info ~doc ~docv []) + and+ value_opt = + let docv = "VALUE" in + let doc = "The new field value" in + Cmdliner.Arg.(value & pos 2 (some string) None & info ~doc ~docv []) + in let open Rresult in (let res = match (action, key_opt, value_opt) with diff --git a/bin/delegate_info.ml b/bin/delegate_info.ml index 0e7cc1e6..7cad388d 100644 --- a/bin/delegate_info.ml +++ b/bin/delegate_info.ml @@ -1,14 +1,13 @@ open Cmdliner open Dune_release -let var = - let doc = "The variable to print." in - Arg.(required & pos 0 (some string) None & info [] ~doc ~docv:"VAR") - let term = Term.( let open Syntax in - let+ var = var in + let+ var = + let doc = "The variable to print." in + Arg.(required & pos 0 (some string) None & info [] ~doc ~docv:"VAR") + in let open Rresult in (let pkg = Pkg.v ~dry_run:false () in let result = diff --git a/bin/help.ml b/bin/help.ml index 238860f2..5c5283aa 100644 --- a/bin/help.ml +++ b/bin/help.ml @@ -247,10 +247,6 @@ let pages = open Cmdliner -let topic = - let doc = "The topic to get help on, `topics' lists the topic." in - Arg.(value & pos 0 (some string) None & info [] ~docv:"TOPIC" ~doc) - let doc = "Show help about dune-release" let exits = Cli.exits let man_xrefs = [ `Main ] @@ -267,7 +263,9 @@ let term = ret (let open Syntax in let+ man_format = Arg.man_format - and+ topic = topic + and+ topic = + let doc = "The topic to get help on, `topics' lists the topic." in + Arg.(value & pos 0 (some string) None & info [] ~docv:"TOPIC" ~doc) and+ commands = Term.choice_names in match topic with | None -> `Help (man_format, None) diff --git a/bin/lint.ml b/bin/lint.ml index 4bbd0e2a..f15869a8 100644 --- a/bin/lint.ml +++ b/bin/lint.ml @@ -11,18 +11,6 @@ open Dune_release open Cmdliner -let lints = - let test = [ ("std-files", `Std_files); ("opam", `Opam) ] in - let doc = - strf - "Test to perform. $(docv) must be one of %s. If unspecified all tests \ - are performed." - (Arg.doc_alts_enum test) - in - let test = Arg.enum test in - let docv = "TEST" in - Arg.(value & pos_all test Lint.all & info [] ~doc ~docv) - let doc = "Check package distribution consistency and conventions" let sdocs = Manpage.s_common_options let exits = Cmd.Exit.info 1 ~doc:"on lint failure" :: Cli.exits @@ -51,7 +39,18 @@ let term = and+ version = Cli.pkg_version and+ tag = Cli.dist_tag and+ keep_v = Cli.keep_v - and+ lints = lints in + and+ lints = + let test = [ ("std-files", `Std_files); ("opam", `Opam) ] in + let doc = + strf + "Test to perform. $(docv) must be one of %s. If unspecified all \ + tests are performed." + (Arg.doc_alts_enum test) + in + let test = Arg.enum test in + let docv = "TEST" in + Arg.(value & pos_all test Lint.all & info [] ~doc ~docv) + in Cli.handle_error ( Config.keep_v ~keep_v >>= fun keep_v -> let pkg = Pkg.v ~dry_run ?version ~keep_v ?tag () in diff --git a/bin/opam.ml b/bin/opam.ml index 2c343ccb..3bbc63b3 100644 --- a/bin/opam.ml +++ b/bin/opam.ml @@ -313,37 +313,6 @@ let field ~pkgs ~field_name = field pkgs field_name open Cmdliner -let action = - let action = - [ ("descr", `Descr); ("pkg", `Pkg); ("submit", `Submit); ("field", `Field) ] - in - let doc = - strf "The action to perform. $(docv) must be one of %s." - (Arg.doc_alts_enum action) - in - let action = Arg.enum action in - Arg.(required & pos 0 (some action) None & info [] ~doc ~docv:"ACTION") - -let field_arg = - let doc = "the field to output ($(b,field) action)" in - Arg.(value & pos 1 (some string) None & info [] ~doc ~docv:"FIELD") - -let pkg_descr = - let doc = - "The opam descr file to use for the opam package. If absent and the opam \ - file name (see $(b,--pkg-opam)) has a `.opam` extension, uses an existing \ - file with the same path but a `.descr` extension. If the opam file name \ - is `opam` uses a `descr` file in the same directory. If these files are \ - not found a description is extracted from the the readme (see option \ - $(b,--readme)) as follow: the first marked up section of the readme is \ - extracted, its title is parsed according to the pattern '\\$(NAME) \ - \\$(SEP) \\$(SYNOPSIS)', the body of the section is the long description. \ - A few lines are filtered out: lines that start with either 'Home page:', \ - 'Contact:' or '%%VERSION'." - in - let docv = "FILE" in - Arg.(value & opt (some Cli.path_arg) None & info [ "pkg-descr" ] ~doc ~docv) - let doc = "Interaction with opam and the OCaml opam repository" let sdocs = Manpage.s_common_options let envs = [] @@ -396,12 +365,43 @@ let term = and+ tag = Cli.dist_tag and+ pkg_names = Cli.pkg_names and+ version = Cli.pkg_version - and+ pkg_descr = pkg_descr + and+ pkg_descr = + let doc = + "The opam descr file to use for the opam package. If absent and the \ + opam file name (see $(b,--pkg-opam)) has a `.opam` extension, uses an \ + existing file with the same path but a `.descr` extension. If the \ + opam file name is `opam` uses a `descr` file in the same directory. \ + If these files are not found a description is extracted from the the \ + readme (see option $(b,--readme)) as follow: the first marked up \ + section of the readme is extracted, its title is parsed according to \ + the pattern '\\$(NAME) \\$(SEP) \\$(SYNOPSIS)', the body of the \ + section is the long description. A few lines are filtered out: lines \ + that start with either 'Home page:', 'Contact:' or '%%VERSION'." + in + let docv = "FILE" in + Arg.( + value & opt (some Cli.path_arg) None & info [ "pkg-descr" ] ~doc ~docv) and+ readme = Cli.readme and+ change_log = Cli.change_log and+ publish_msg = Cli.publish_msg - and+ action = action - and+ field_name = field_arg + and+ action = + let action = + [ + ("descr", `Descr); + ("pkg", `Pkg); + ("submit", `Submit); + ("field", `Field); + ] + in + let doc = + strf "The action to perform. $(docv) must be one of %s." + (Arg.doc_alts_enum action) + in + let action = Arg.enum action in + Arg.(required & pos 0 (some action) None & info [] ~doc ~docv:"ACTION") + and+ field_name = + let doc = "the field to output ($(b,field) action)" in + Arg.(value & pos 1 (some string) None & info [] ~doc ~docv:"FIELD") and+ no_auto_open = Cli.no_auto_open and+ yes = Cli.yes and+ token = Cli.token diff --git a/bin/tag.ml b/bin/tag.ml index 8bd2ecc7..b1ac27c2 100644 --- a/bin/tag.ml +++ b/bin/tag.ml @@ -75,37 +75,6 @@ let vcs_tag repo pkg tag version ~dry_run ~commit_ish ~force ~sign ~delete ~msg open Cmdliner -let version = - let doc = - "The version tag to use. If absent, automatically extracted from the \ - package's change log." - in - Arg.(value & pos 0 (some Cli.version) None & info [] ~doc ~docv:"VERSION") - -let commit = - let doc = "Commit-ish $(docv) to tag." in - Arg.(value & opt string "HEAD" & info [ "commit" ] ~doc ~docv:"COMMIT-ISH") - -let msg = - let doc = - "Commit message for the tag. If absent, the message 'Distribution \ - $(i,VERSION)' is used." - in - Arg.( - value & opt (some string) None & info [ "m"; "message" ] ~doc ~docv:"MSG") - -let sign = - let doc = "Sign the tag using the VCS's default signing key." in - Arg.(value & flag & info [ "s"; "sign" ] ~doc) - -let force = - let doc = "If the tag exists, replace it rather than fail." in - Arg.(value & flag & info [ "f"; "force" ] ~doc) - -let delete = - let doc = "Delete the specified tag rather than create it." in - Arg.(value & flag & info [ "d"; "delete" ] ~doc) - let doc = "Tag the package's source repository with a version" let sdocs = Manpage.s_common_options let exits = Cli.exits @@ -127,12 +96,34 @@ let term = and+ dry_run = Cli.dry_run and+ change_log = Cli.change_log and+ keep_v = Cli.keep_v - and+ version = version - and+ commit_ish = commit - and+ force = force - and+ sign = sign - and+ delete = delete - and+ msg = msg + and+ version = + let doc = + "The version tag to use. If absent, automatically extracted from the \ + package's change log." + in + Arg.(value & pos 0 (some Cli.version) None & info [] ~doc ~docv:"VERSION") + and+ commit_ish = + let doc = "Commit-ish $(docv) to tag." in + Arg.( + value & opt string "HEAD" & info [ "commit" ] ~doc ~docv:"COMMIT-ISH") + and+ force = + let doc = "If the tag exists, replace it rather than fail." in + Arg.(value & flag & info [ "f"; "force" ] ~doc) + and+ sign = + let doc = "Sign the tag using the VCS's default signing key." in + Arg.(value & flag & info [ "s"; "sign" ] ~doc) + and+ delete = + let doc = "Delete the specified tag rather than create it." in + Arg.(value & flag & info [ "d"; "delete" ] ~doc) + and+ msg = + let doc = + "Commit message for the tag. If absent, the message 'Distribution \ + $(i,VERSION)' is used." + in + Arg.( + value + & opt (some string) None + & info [ "m"; "message" ] ~doc ~docv:"MSG") and+ yes = Cli.yes in Config.keep_v ~keep_v >>= (fun keep_v ->