Skip to content

Commit 5f2f47e

Browse files
committed
inline cmdliner terms
I think this style is generally preferred. This change was made purely mechanically with: ocamlmig replace -e '[%binding let+ __pat = [%move_def __f] in __] /// [%binding let+ __pat = __f in __]' -w
1 parent e7137d2 commit 5f2f47e

File tree

8 files changed

+118
-140
lines changed

8 files changed

+118
-140
lines changed

Diff for: bin/check.ml

+4-5
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ let clone_and_checkout_tag repo ~dir ~tag =
1414

1515
open Cmdliner
1616

17-
let working_tree =
18-
let doc = "Perform the check on the current working tree." in
19-
Arg.(value & flag & info [ "working-tree" ] ~doc)
20-
2117
let doc = "Check dune-release compatibility"
2218

2319
let man =
@@ -44,7 +40,10 @@ let term =
4440
and+ skip_build = Cli.skip_build
4541
and+ skip_tests = Cli.skip_tests
4642
and+ skip_change_log = Cli.skip_change_log
47-
and+ on_working_tree = working_tree in
43+
and+ on_working_tree =
44+
let doc = "Perform the check on the current working tree." in
45+
Arg.(value & flag & info [ "working-tree" ] ~doc)
46+
in
4847
(let dir, clean_up =
4948
if on_working_tree then (OS.Dir.current (), fun _ -> ())
5049
else

Diff for: bin/cli.ml

+14-19
Original file line numberDiff line numberDiff line change
@@ -244,28 +244,23 @@ let keep_build_dir =
244244
(* use cmdliner evaluation error *)
245245

246246
let setup =
247-
let style_renderer =
248-
let env = Cmd.Env.info "DUNE_RELEASE_COLOR" in
249-
Fmt_cli.style_renderer ~docs:Manpage.s_common_options ~env ()
250-
in
251-
let log_level =
252-
let env = Cmd.Env.info "DUNE_RELEASE_VERBOSITY" in
253-
Logs_cli.level ~docs:Manpage.s_common_options ~env ()
254-
in
255-
let cwd =
256-
let doc = "Change to directory $(docv) before doing anything." in
257-
let docv = "DIR" in
258-
Arg.(
259-
value
260-
& opt (some path_arg) None
261-
& info [ "C"; "pkg-dir" ] ~docs:Manpage.s_common_options ~doc ~docv)
262-
in
263247
Term.(
264248
ret
265249
(let open Syntax in
266-
let+ style_renderer = style_renderer
267-
and+ log_level = log_level
268-
and+ cwd = cwd in
250+
let+ style_renderer =
251+
let env = Cmd.Env.info "DUNE_RELEASE_COLOR" in
252+
Fmt_cli.style_renderer ~docs:Manpage.s_common_options ~env ()
253+
and+ log_level =
254+
let env = Cmd.Env.info "DUNE_RELEASE_VERBOSITY" in
255+
Logs_cli.level ~docs:Manpage.s_common_options ~env ()
256+
and+ cwd =
257+
let doc = "Change to directory $(docv) before doing anything." in
258+
let docv = "DIR" in
259+
Arg.(
260+
value
261+
& opt (some path_arg) None
262+
& info [ "C"; "pkg-dir" ] ~docs:Manpage.s_common_options ~doc ~docv)
263+
in
269264
Fmt_tty.setup_std_outputs ?style_renderer ();
270265
Logs.set_level log_level;
271266
Logs.set_reporter (Logs_fmt.reporter ~app:Fmt.stdout ());

Diff for: bin/config.ml

+19-22
Original file line numberDiff line numberDiff line change
@@ -141,31 +141,28 @@ let man =
141141
newly created opam-repository PR or not.";
142142
]
143143

144-
let action =
145-
let docv = "ACTION" in
146-
let doc =
147-
"The action to perform, either $(b,show) the config or $(b,set) a config \
148-
field"
149-
in
150-
Cmdliner.Arg.(value & pos 0 string "show" & info ~doc ~docv [])
151-
152-
let key =
153-
let docv = "KEY" in
154-
let doc =
155-
"The configuration field to set or print. For $(b,show), if no key is \
156-
provided, the entire config will be printed."
157-
in
158-
Cmdliner.Arg.(value & pos 1 (some string) None & info ~doc ~docv [])
159-
160-
let value =
161-
let docv = "VALUE" in
162-
let doc = "The new field value" in
163-
Cmdliner.Arg.(value & pos 2 (some string) None & info ~doc ~docv [])
164-
165144
let term =
166145
Cmdliner.Term.(
167146
let open Syntax in
168-
let+ action = action and+ key_opt = key and+ value_opt = value in
147+
let+ action =
148+
let docv = "ACTION" in
149+
let doc =
150+
"The action to perform, either $(b,show) the config or $(b,set) a \
151+
config field"
152+
in
153+
Cmdliner.Arg.(value & pos 0 string "show" & info ~doc ~docv [])
154+
and+ key_opt =
155+
let docv = "KEY" in
156+
let doc =
157+
"The configuration field to set or print. For $(b,show), if no key is \
158+
provided, the entire config will be printed."
159+
in
160+
Cmdliner.Arg.(value & pos 1 (some string) None & info ~doc ~docv [])
161+
and+ value_opt =
162+
let docv = "VALUE" in
163+
let doc = "The new field value" in
164+
Cmdliner.Arg.(value & pos 2 (some string) None & info ~doc ~docv [])
165+
in
169166
let open Rresult in
170167
(let res =
171168
match (action, key_opt, value_opt) with

Diff for: bin/delegate_info.ml

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
open Cmdliner
22
open Dune_release
33

4-
let var =
5-
let doc = "The variable to print." in
6-
Arg.(required & pos 0 (some string) None & info [] ~doc ~docv:"VAR")
7-
84
let term =
95
Term.(
106
let open Syntax in
11-
let+ var = var in
7+
let+ var =
8+
let doc = "The variable to print." in
9+
Arg.(required & pos 0 (some string) None & info [] ~doc ~docv:"VAR")
10+
in
1211
let open Rresult in
1312
(let pkg = Pkg.v ~dry_run:false () in
1413
let result =

Diff for: bin/help.ml

+3-5
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,6 @@ let pages =
247247

248248
open Cmdliner
249249

250-
let topic =
251-
let doc = "The topic to get help on, `topics' lists the topic." in
252-
Arg.(value & pos 0 (some string) None & info [] ~docv:"TOPIC" ~doc)
253-
254250
let doc = "Show help about dune-release"
255251
let exits = Cli.exits
256252
let man_xrefs = [ `Main ]
@@ -267,7 +263,9 @@ let term =
267263
ret
268264
(let open Syntax in
269265
let+ man_format = Arg.man_format
270-
and+ topic = topic
266+
and+ topic =
267+
let doc = "The topic to get help on, `topics' lists the topic." in
268+
Arg.(value & pos 0 (some string) None & info [] ~docv:"TOPIC" ~doc)
271269
and+ commands = Term.choice_names in
272270
match topic with
273271
| None -> `Help (man_format, None)

Diff for: bin/lint.ml

+12-13
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@ open Dune_release
1111

1212
open Cmdliner
1313

14-
let lints =
15-
let test = [ ("std-files", `Std_files); ("opam", `Opam) ] in
16-
let doc =
17-
strf
18-
"Test to perform. $(docv) must be one of %s. If unspecified all tests \
19-
are performed."
20-
(Arg.doc_alts_enum test)
21-
in
22-
let test = Arg.enum test in
23-
let docv = "TEST" in
24-
Arg.(value & pos_all test Lint.all & info [] ~doc ~docv)
25-
2614
let doc = "Check package distribution consistency and conventions"
2715
let sdocs = Manpage.s_common_options
2816
let exits = Cmd.Exit.info 1 ~doc:"on lint failure" :: Cli.exits
@@ -51,7 +39,18 @@ let term =
5139
and+ version = Cli.pkg_version
5240
and+ tag = Cli.dist_tag
5341
and+ keep_v = Cli.keep_v
54-
and+ lints = lints in
42+
and+ lints =
43+
let test = [ ("std-files", `Std_files); ("opam", `Opam) ] in
44+
let doc =
45+
strf
46+
"Test to perform. $(docv) must be one of %s. If unspecified all \
47+
tests are performed."
48+
(Arg.doc_alts_enum test)
49+
in
50+
let test = Arg.enum test in
51+
let docv = "TEST" in
52+
Arg.(value & pos_all test Lint.all & info [] ~doc ~docv)
53+
in
5554
Cli.handle_error
5655
( Config.keep_v ~keep_v >>= fun keep_v ->
5756
let pkg = Pkg.v ~dry_run ?version ~keep_v ?tag () in

Diff for: bin/opam.ml

+34-34
Original file line numberDiff line numberDiff line change
@@ -313,37 +313,6 @@ let field ~pkgs ~field_name = field pkgs field_name
313313

314314
open Cmdliner
315315

316-
let action =
317-
let action =
318-
[ ("descr", `Descr); ("pkg", `Pkg); ("submit", `Submit); ("field", `Field) ]
319-
in
320-
let doc =
321-
strf "The action to perform. $(docv) must be one of %s."
322-
(Arg.doc_alts_enum action)
323-
in
324-
let action = Arg.enum action in
325-
Arg.(required & pos 0 (some action) None & info [] ~doc ~docv:"ACTION")
326-
327-
let field_arg =
328-
let doc = "the field to output ($(b,field) action)" in
329-
Arg.(value & pos 1 (some string) None & info [] ~doc ~docv:"FIELD")
330-
331-
let pkg_descr =
332-
let doc =
333-
"The opam descr file to use for the opam package. If absent and the opam \
334-
file name (see $(b,--pkg-opam)) has a `.opam` extension, uses an existing \
335-
file with the same path but a `.descr` extension. If the opam file name \
336-
is `opam` uses a `descr` file in the same directory. If these files are \
337-
not found a description is extracted from the the readme (see option \
338-
$(b,--readme)) as follow: the first marked up section of the readme is \
339-
extracted, its title is parsed according to the pattern '\\$(NAME) \
340-
\\$(SEP) \\$(SYNOPSIS)', the body of the section is the long description. \
341-
A few lines are filtered out: lines that start with either 'Home page:', \
342-
'Contact:' or '%%VERSION'."
343-
in
344-
let docv = "FILE" in
345-
Arg.(value & opt (some Cli.path_arg) None & info [ "pkg-descr" ] ~doc ~docv)
346-
347316
let doc = "Interaction with opam and the OCaml opam repository"
348317
let sdocs = Manpage.s_common_options
349318
let envs = []
@@ -396,12 +365,43 @@ let term =
396365
and+ tag = Cli.dist_tag
397366
and+ pkg_names = Cli.pkg_names
398367
and+ version = Cli.pkg_version
399-
and+ pkg_descr = pkg_descr
368+
and+ pkg_descr =
369+
let doc =
370+
"The opam descr file to use for the opam package. If absent and the \
371+
opam file name (see $(b,--pkg-opam)) has a `.opam` extension, uses an \
372+
existing file with the same path but a `.descr` extension. If the \
373+
opam file name is `opam` uses a `descr` file in the same directory. \
374+
If these files are not found a description is extracted from the the \
375+
readme (see option $(b,--readme)) as follow: the first marked up \
376+
section of the readme is extracted, its title is parsed according to \
377+
the pattern '\\$(NAME) \\$(SEP) \\$(SYNOPSIS)', the body of the \
378+
section is the long description. A few lines are filtered out: lines \
379+
that start with either 'Home page:', 'Contact:' or '%%VERSION'."
380+
in
381+
let docv = "FILE" in
382+
Arg.(
383+
value & opt (some Cli.path_arg) None & info [ "pkg-descr" ] ~doc ~docv)
400384
and+ readme = Cli.readme
401385
and+ change_log = Cli.change_log
402386
and+ publish_msg = Cli.publish_msg
403-
and+ action = action
404-
and+ field_name = field_arg
387+
and+ action =
388+
let action =
389+
[
390+
("descr", `Descr);
391+
("pkg", `Pkg);
392+
("submit", `Submit);
393+
("field", `Field);
394+
]
395+
in
396+
let doc =
397+
strf "The action to perform. $(docv) must be one of %s."
398+
(Arg.doc_alts_enum action)
399+
in
400+
let action = Arg.enum action in
401+
Arg.(required & pos 0 (some action) None & info [] ~doc ~docv:"ACTION")
402+
and+ field_name =
403+
let doc = "the field to output ($(b,field) action)" in
404+
Arg.(value & pos 1 (some string) None & info [] ~doc ~docv:"FIELD")
405405
and+ no_auto_open = Cli.no_auto_open
406406
and+ yes = Cli.yes
407407
and+ token = Cli.token

Diff for: bin/tag.ml

+28-37
Original file line numberDiff line numberDiff line change
@@ -75,37 +75,6 @@ let vcs_tag repo pkg tag version ~dry_run ~commit_ish ~force ~sign ~delete ~msg
7575

7676
open Cmdliner
7777

78-
let version =
79-
let doc =
80-
"The version tag to use. If absent, automatically extracted from the \
81-
package's change log."
82-
in
83-
Arg.(value & pos 0 (some Cli.version) None & info [] ~doc ~docv:"VERSION")
84-
85-
let commit =
86-
let doc = "Commit-ish $(docv) to tag." in
87-
Arg.(value & opt string "HEAD" & info [ "commit" ] ~doc ~docv:"COMMIT-ISH")
88-
89-
let msg =
90-
let doc =
91-
"Commit message for the tag. If absent, the message 'Distribution \
92-
$(i,VERSION)' is used."
93-
in
94-
Arg.(
95-
value & opt (some string) None & info [ "m"; "message" ] ~doc ~docv:"MSG")
96-
97-
let sign =
98-
let doc = "Sign the tag using the VCS's default signing key." in
99-
Arg.(value & flag & info [ "s"; "sign" ] ~doc)
100-
101-
let force =
102-
let doc = "If the tag exists, replace it rather than fail." in
103-
Arg.(value & flag & info [ "f"; "force" ] ~doc)
104-
105-
let delete =
106-
let doc = "Delete the specified tag rather than create it." in
107-
Arg.(value & flag & info [ "d"; "delete" ] ~doc)
108-
10978
let doc = "Tag the package's source repository with a version"
11079
let sdocs = Manpage.s_common_options
11180
let exits = Cli.exits
@@ -127,12 +96,34 @@ let term =
12796
and+ dry_run = Cli.dry_run
12897
and+ change_log = Cli.change_log
12998
and+ keep_v = Cli.keep_v
130-
and+ version = version
131-
and+ commit_ish = commit
132-
and+ force = force
133-
and+ sign = sign
134-
and+ delete = delete
135-
and+ msg = msg
99+
and+ version =
100+
let doc =
101+
"The version tag to use. If absent, automatically extracted from the \
102+
package's change log."
103+
in
104+
Arg.(value & pos 0 (some Cli.version) None & info [] ~doc ~docv:"VERSION")
105+
and+ commit_ish =
106+
let doc = "Commit-ish $(docv) to tag." in
107+
Arg.(
108+
value & opt string "HEAD" & info [ "commit" ] ~doc ~docv:"COMMIT-ISH")
109+
and+ force =
110+
let doc = "If the tag exists, replace it rather than fail." in
111+
Arg.(value & flag & info [ "f"; "force" ] ~doc)
112+
and+ sign =
113+
let doc = "Sign the tag using the VCS's default signing key." in
114+
Arg.(value & flag & info [ "s"; "sign" ] ~doc)
115+
and+ delete =
116+
let doc = "Delete the specified tag rather than create it." in
117+
Arg.(value & flag & info [ "d"; "delete" ] ~doc)
118+
and+ msg =
119+
let doc =
120+
"Commit message for the tag. If absent, the message 'Distribution \
121+
$(i,VERSION)' is used."
122+
in
123+
Arg.(
124+
value
125+
& opt (some string) None
126+
& info [ "m"; "message" ] ~doc ~docv:"MSG")
136127
and+ yes = Cli.yes in
137128
Config.keep_v ~keep_v
138129
>>= (fun keep_v ->

0 commit comments

Comments
 (0)