Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade cmdliner fork to 1.1.1 #6038

Merged
merged 1 commit into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
- Add `%{coq:...}` macro for accessing data about the configuration about Coq.
For instance `%{coq:version}` (#6049, @Alizter)

- update vendored copy of cmdliner to 1.1.1. This improves the built-in
documentation for command groups such as `dune ocaml`. (#6038, @emillon)

3.4.1 (26-07-2022)
------------------

Expand Down
36 changes: 19 additions & 17 deletions bin/build_cmd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ let run_build_command ~(common : Common.t) ~config ~request =
| No -> run_build_command_once)
~common ~config ~request

let runtest =
let runtest_info =
let doc = "Run tests." in
let man =
[ `S "DESCRIPTION"
Expand All @@ -131,22 +131,24 @@ let runtest =
]
]
in
Cmd.info "runtest" ~doc ~man

let runtest_term =
let name_ = Arg.info [] ~docv:"DIR" in
let term =
let+ common = Common.term
and+ dirs = Arg.(value & pos_all string [ "." ] name_) in
let config = Common.init common in
let request (setup : Import.Main.build_system) =
Action_builder.all_unit
(List.map dirs ~f:(fun dir ->
let dir = Path.(relative root) (Common.prefix_target common dir) in
Alias.in_dir ~name:Dune_engine.Alias.Name.runtest ~recursive:true
~contexts:setup.contexts dir
|> Alias.request))
in
run_build_command ~common ~config ~request
let+ common = Common.term
and+ dirs = Arg.(value & pos_all string [ "." ] name_) in
let config = Common.init common in
let request (setup : Import.Main.build_system) =
Action_builder.all_unit
(List.map dirs ~f:(fun dir ->
let dir = Path.(relative root) (Common.prefix_target common dir) in
Alias.in_dir ~name:Dune_engine.Alias.Name.runtest ~recursive:true
~contexts:setup.contexts dir
|> Alias.request))
in
(term, Term.info "runtest" ~doc ~man)
run_build_command ~common ~config ~request

let runtest = Cmd.v runtest_info runtest_term

let build =
let doc =
Expand Down Expand Up @@ -182,7 +184,7 @@ let build =
in
run_build_command ~common ~config ~request
in
(term, Term.info "build" ~doc ~man)
Cmd.v (Cmd.info "build" ~doc ~man) term

let fmt =
let doc = "Format source code." in
Expand All @@ -207,4 +209,4 @@ let fmt =
in
run_build_command ~common ~config ~request
in
(term, Term.info "fmt" ~doc ~man)
Cmd.v (Cmd.info "fmt" ~doc ~man) term
12 changes: 7 additions & 5 deletions bin/build_cmd.mli
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
open Dune_engine
open Import

val run_build_command :
common:Common.t
-> config:Dune_config.t
-> request:(Dune_rules.Main.build_system -> unit Action_builder.t)
-> request:(Main.build_system -> unit Action_builder.t)
-> unit

val runtest : unit Cmdliner.Term.t * Cmdliner.Term.info
val runtest : unit Cmd.t

val build : unit Cmdliner.Term.t * Cmdliner.Term.info
val runtest_term : unit Term.t

val fmt : unit Cmdliner.Term.t * Cmdliner.Term.info
val build : unit Cmd.t

val fmt : unit Cmd.t
4 changes: 2 additions & 2 deletions bin/cache.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let man =

let doc = "Manage the shared cache of build artifacts"

let info = Term.info name ~doc ~man
let info = Cmd.info name ~doc ~man

let trim ~trimmed_size ~size =
Log.init_disabled ();
Expand Down Expand Up @@ -87,4 +87,4 @@ let term =
| Some Start_deprecated | Some Stop_deprecated -> deprecated_error ()
| None -> `Help (`Pager, Some name)

let command = (term, info)
let command = Cmd.v info term
4 changes: 3 additions & 1 deletion bin/cache.mli
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
val command : unit Cmdliner.Term.t * Cmdliner.Term.info
open Import

val command : unit Cmd.t
2 changes: 1 addition & 1 deletion bin/clean.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ let command =
|> Path.Set.iter ~f:Path.unlink_no_err;
Path.rm_rf Path.build_dir
in
(term, Term.info "clean" ~doc ~man)
Cmd.v (Cmd.info "clean" ~doc ~man) term
4 changes: 3 additions & 1 deletion bin/clean.mli
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
val command : unit Cmdliner.Term.t * Cmdliner.Term.info
open Import

val command : unit Cmd.t
23 changes: 12 additions & 11 deletions bin/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Clflags = Dune_engine.Clflags
module Graph = Dune_graph.Graph
module Package = Dune_engine.Package
module Profile = Dune_rules.Profile
module Cmd = Cmdliner.Cmd
module Term = Cmdliner.Term
module Manpage = Cmdliner.Manpage
module Only_packages = Dune_rules.Only_packages
Expand Down Expand Up @@ -506,7 +507,7 @@ module Options_implied_by_dash_p = struct
last
& opt_all (some profile) [ None ]
& info [ "profile" ] ~docs
~env:(Arg.env_var ~doc "DUNE_PROFILE")
~env:(Cmd.Env.info ~doc "DUNE_PROFILE")
~doc:
(Printf.sprintf
"Select the build profile, for instance $(b,dev) or \
Expand Down Expand Up @@ -561,7 +562,7 @@ let shared_with_config_file =
& opt (some (enum all)) None
& info [ "sandbox" ]
~env:
(Arg.env_var
(Cmd.Env.info
~doc:"Sandboxing mode to use by default. (see --sandbox)"
"DUNE_SANDBOX")
~doc:
Expand Down Expand Up @@ -597,7 +598,7 @@ let shared_with_config_file =
Arg.(
value
& opt (some (enum Dune_config.Cache.Enabled.all)) None
& info [ "cache" ] ~docs ~env:(Arg.env_var ~doc "DUNE_CACHE") ~doc)
& info [ "cache" ] ~docs ~env:(Cmd.Env.info ~doc "DUNE_CACHE") ~doc)
and+ cache_storage_mode =
let doc =
Printf.sprintf "Dune cache storage mode (%s). Default is `%s'."
Expand All @@ -609,7 +610,7 @@ let shared_with_config_file =
value
& opt (some (enum Dune_config.Cache.Storage_mode.all)) None
& info [ "cache-storage-mode" ] ~docs
~env:(Arg.env_var ~doc "DUNE_CACHE_STORAGE_MODE")
~env:(Cmd.Env.info ~doc "DUNE_CACHE_STORAGE_MODE")
~doc)
and+ cache_check_probability =
let doc =
Expand All @@ -625,7 +626,7 @@ let shared_with_config_file =
& info
[ "cache-check-probability" ]
~docs
~env:(Arg.env_var ~doc "DUNE_CACHE_CHECK_PROBABILITY")
~env:(Cmd.Env.info ~doc "DUNE_CACHE_CHECK_PROBABILITY")
~doc)
and+ action_stdout_on_success =
Arg.(
Expand Down Expand Up @@ -790,7 +791,7 @@ let term ~default_root_is_cwd =
value
& opt (some path) None
& info [ "workspace" ] ~docs ~docv:"FILE" ~doc
~env:(Arg.env_var ~doc "DUNE_WORKSPACE"))
~env:(Cmd.Env.info ~doc "DUNE_WORKSPACE"))
and+ promote =
one_of
(let+ auto =
Expand All @@ -804,7 +805,7 @@ let term ~default_root_is_cwd =
Option.some_if auto Clflags.Promote.Automatically)
(let+ disable =
let doc = "Disable all promotion rules" in
let env = Arg.env_var ~doc "DUNE_DISABLE_PROMOTION" in
let env = Cmd.Env.info ~doc "DUNE_DISABLE_PROMOTION" in
Arg.(value & flag & info [ "disable-promotion" ] ~docs ~env ~doc)
in
Option.some_if disable Clflags.Promote.Never)
Expand Down Expand Up @@ -892,7 +893,7 @@ let term ~default_root_is_cwd =
value
& opt (some string) None
& info [ "build-dir" ] ~docs ~docv:"FILE"
~env:(Arg.env_var ~doc "DUNE_BUILD_DIR")
~env:(Cmd.Env.info ~doc "DUNE_BUILD_DIR")
~doc)
and+ diff_command =
let doc =
Expand All @@ -903,7 +904,7 @@ let term ~default_root_is_cwd =
value
& opt (some string) None
& info [ "diff-command" ] ~docs
~env:(Arg.env_var ~doc "DUNE_DIFF_COMMAND")
~env:(Cmd.Env.info ~doc "DUNE_DIFF_COMMAND")
~doc)
and+ stats_trace_file =
Arg.(
Expand All @@ -925,7 +926,7 @@ let term ~default_root_is_cwd =
& info
[ "store-orig-source-dir" ]
~docs
~env:(Arg.env_var ~doc "DUNE_STORE_ORIG_SOURCE_DIR")
~env:(Cmd.Env.info ~doc "DUNE_STORE_ORIG_SOURCE_DIR")
~doc)
and+ () = build_info
and+ instrument_with =
Expand All @@ -938,7 +939,7 @@ let term ~default_root_is_cwd =
value
& opt (some (list lib_name)) None
& info [ "instrument-with" ] ~docs
~env:(Arg.env_var ~doc "DUNE_INSTRUMENT_WITH")
~env:(Cmd.Env.info ~doc "DUNE_INSTRUMENT_WITH")
~docv:"BACKENDS" ~doc)
and+ file_watcher =
let doc =
Expand Down
4 changes: 2 additions & 2 deletions bin/coq.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ let sub_commands_synopsis = Common.command_synopsis [ "coq top FILE -- ARGS" ]

let man = [ `Blocks sub_commands_synopsis ]

let info = Term.info ~doc ~man "coq"
let info = Cmd.info ~doc ~man "coq"

let group = (Term.Group.Group [ in_group Coqtop.command ], info)
let group = Cmd.group info [ Coqtop.command ]
2 changes: 1 addition & 1 deletion bin/coq.mli
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
open Import

val group : unit Term.Group.t
val group : unit Cmd.t
4 changes: 2 additions & 2 deletions bin/coqtop.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let man =
; `Blocks Common.help_secs
]

let info = Term.info "top" ~doc ~man
let info = Cmd.info "top" ~doc ~man

let term =
let+ common = Common.term
Expand Down Expand Up @@ -137,4 +137,4 @@ let term =
in
restore_cwd_and_execve common coqtop argv env

let command = (term, info)
let command = Cmd.v info term
4 changes: 3 additions & 1 deletion bin/coqtop.mli
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
val command : unit Cmdliner.Term.t * Cmdliner.Term.info
open Import

val command : unit Cmd.t
4 changes: 2 additions & 2 deletions bin/describe.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let man =
; `Blocks Common.help_secs
]

let info = Term.info "describe" ~doc ~man
let info = Cmd.info "describe" ~doc ~man

(** whether to sanitize absolute paths of workspace items, and their UIDs, to
ensure reproducible tests *)
Expand Down Expand Up @@ -869,4 +869,4 @@ let term : unit Term.t =
| Csexp -> Csexp.to_channel stdout (Sexp.of_dyn res)
| Sexp -> print_as_sexp res))

let command : unit Term.t * Term.info = (term, info)
let command = Cmd.v info term
4 changes: 3 additions & 1 deletion bin/describe.mli
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
val command : unit Cmdliner.Term.t * Cmdliner.Term.info
open Import

val command : unit Cmd.t
4 changes: 2 additions & 2 deletions bin/diagnostics.ml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ let exec () =

let info =
let doc = "fetch and return errors from the current build" in
Term.info "diagnostics" ~doc
Cmd.info "diagnostics" ~doc

let term =
let+ (common : Common.t) = Common.term in
Rpc.client_term common exec

let command = (term, info)
let command = Cmd.v info term
2 changes: 1 addition & 1 deletion bin/diagnostics.mli
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
open Import

val command : unit Term.t * Term.info
val command : unit Cmd.t
4 changes: 2 additions & 2 deletions bin/exec.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let man =
]
]

let info = Term.info "exec" ~doc ~man
let info = Cmd.info "exec" ~doc ~man

let term =
let+ common = Common.term
Expand Down Expand Up @@ -132,4 +132,4 @@ let term =
in
restore_cwd_and_execve common prog argv env

let command = (term, info)
let command = Cmd.v info term
4 changes: 3 additions & 1 deletion bin/exec.mli
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
val command : unit Cmdliner.Term.t * Cmdliner.Term.info
open Import

val command : unit Cmd.t
4 changes: 2 additions & 2 deletions bin/external_lib_deps.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let man =
; `Blocks Common.help_secs
]

let info = Term.info "external-lib-deps" ~doc ~man
let info = Cmd.info "external-lib-deps" ~doc ~man

let term =
Term.ret
Expand All @@ -25,4 +25,4 @@ let term =
and+ _ = Arg.(value & flag & info [ "sexp" ] ~doc:{|unused|}) in
`Error (false, "This subcommand is no longer implemented.")

let command = (term, info)
let command = Cmd.v info term
4 changes: 3 additions & 1 deletion bin/external_lib_deps.mli
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
val command : unit Cmdliner.Term.t * Cmdliner.Term.info
open Import

val command : unit Cmd.t
4 changes: 2 additions & 2 deletions bin/format_dune_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let man =
formatting" section in the manual.|}
]

let info = Term.info "format-dune-file" ~doc ~man
let info = Cmd.info "format-dune-file" ~doc ~man

let format_file ~version ~input =
let with_input =
Expand Down Expand Up @@ -50,4 +50,4 @@ let term =
let input = Option.map ~f:Arg.Path.path path_opt in
format_file ~version ~input

let command = (term, info)
let command = Cmd.v info term
4 changes: 3 additions & 1 deletion bin/format_dune_file.mli
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
val command : unit Cmdliner.Term.t * Cmdliner.Term.info
open Import

val command : unit Cmd.t
4 changes: 2 additions & 2 deletions bin/help.ml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ let man =
; Common.footer
]

let info = Term.info "help" ~doc ~man
let info = Cmd.info "help" ~doc ~man

let term =
Term.ret
Expand All @@ -124,4 +124,4 @@ let term =
|> String.concat ~sep:"\n" |> print_endline;
`Ok ()

let command = (term, info)
let command = Cmd.v info term
4 changes: 3 additions & 1 deletion bin/help.mli
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
val command : unit Cmdliner.Term.t * Cmdliner.Term.info
open Import

val command : unit Cmd.t
Loading