Skip to content

Commit 0c3a6ff

Browse files
Merge pull request #429 from NathanReb/update-cmdliner
Fix compat with cmdliner 1.1+
2 parents d27c315 + e804df6 commit 0c3a6ff

28 files changed

+119
-116
lines changed

CHANGES.md

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
### Fixed
1010

11+
- Fix compatibility with Cmdliner 1.1.0. This also unfortunately means that the
12+
minimum OCaml version is 4.08 now. (#429, @NathanReb)
13+
1114
### Removed
1215

1316
### Security

bin/bistro.ml

+9-8
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ let man =
5050
`P "See dune-release(7) for more information.";
5151
]
5252

53-
let cmd =
54-
( Term.(
55-
pure bistro $ Cli.setup $ Cli.dry_run $ Cli.pkg_names $ Cli.pkg_version
56-
$ Cli.dist_tag $ Cli.keep_v $ Cli.token $ Cli.include_submodules
57-
$ Cli.draft $ Cli.keep_build_dir $ Cli.skip_lint $ Cli.skip_build
58-
$ Cli.skip_tests $ Cli.local_repo $ Cli.remote_repo $ Cli.opam_repo
59-
$ Cli.no_auto_open),
60-
Term.info "bistro" ~doc ~sdocs ~exits ~man ~man_xrefs )
53+
let term =
54+
Term.(
55+
const bistro $ Cli.setup $ Cli.dry_run $ Cli.pkg_names $ Cli.pkg_version
56+
$ Cli.dist_tag $ Cli.keep_v $ Cli.token $ Cli.include_submodules $ Cli.draft
57+
$ Cli.keep_build_dir $ Cli.skip_lint $ Cli.skip_build $ Cli.skip_tests
58+
$ Cli.local_repo $ Cli.remote_repo $ Cli.opam_repo $ Cli.no_auto_open)
59+
60+
let info = Cmd.info "bistro" ~doc ~sdocs ~exits ~man ~man_xrefs
61+
let cmd = Cmd.v info term
6162

6263
(*---------------------------------------------------------------------------
6364
Copyright (c) 2016 Daniel C. Bünzli

bin/bistro.mli

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
(** The [bistro] command. *)
88

9-
val cmd : int Cmdliner.Term.t * Cmdliner.Term.info
9+
val term : int Cmdliner.Term.t
10+
val cmd : int Cmdliner.Cmd.t
1011

1112
(*---------------------------------------------------------------------------
1213
Copyright (c) 2016 Daniel C. Bünzli

bin/check.ml

+8-6
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ let man =
7676
dune-release creates the distribution tarball.";
7777
]
7878

79-
let cmd =
80-
( Term.(
81-
const check $ Cli.pkg_names $ Cli.pkg_version $ Cli.dist_tag $ Cli.keep_v
82-
$ Cli.build_dir $ Cli.skip_lint $ Cli.skip_build $ Cli.skip_tests
83-
$ working_tree),
84-
Term.info "check" ~doc ~man )
79+
let term =
80+
Term.(
81+
const check $ Cli.pkg_names $ Cli.pkg_version $ Cli.dist_tag $ Cli.keep_v
82+
$ Cli.build_dir $ Cli.skip_lint $ Cli.skip_build $ Cli.skip_tests
83+
$ working_tree)
84+
85+
let info = Cmd.info "check" ~doc ~man
86+
let cmd = Cmd.v info term

bin/check.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
(** The [check] command. *)
22

3-
val cmd : int Cmdliner.Term.t * Cmdliner.Term.info
3+
val cmd : int Cmdliner.Cmd.t

bin/cli.ml

+8-17
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ let token =
8282
token is provided through an environment variable."
8383
in
8484
let docv = "TOKEN" in
85-
let env = Arg.env_var "DUNE_RELEASE_GITHUB_TOKEN" in
85+
let env = Cmd.Env.info "DUNE_RELEASE_GITHUB_TOKEN" in
8686
let arg =
8787
Arg.(value & opt (some string) None & info [ "token" ] ~doc ~docv ~env)
8888
in
@@ -207,7 +207,7 @@ let user =
207207

208208
let local_repo =
209209
let doc = "Location of the local fork of opam-repository" in
210-
let env = Arg.env_var "DUNE_RELEASE_LOCAL_REPO" in
210+
let env = Cmd.Env.info "DUNE_RELEASE_LOCAL_REPO" in
211211
let arg =
212212
Arg.(
213213
value
@@ -218,7 +218,7 @@ let local_repo =
218218

219219
let remote_repo =
220220
let doc = "Location of the remote fork of opam-repository" in
221-
let env = Arg.env_var "DUNE_RELEASE_REMOTE_REPO" in
221+
let env = Cmd.Env.info "DUNE_RELEASE_REMOTE_REPO" in
222222
let arg =
223223
Arg.(
224224
value
@@ -233,7 +233,7 @@ let opam_repo =
233233
to release to a custom repo. Useful for testing purposes."
234234
in
235235
let docv = "GITHUB_USER_OR_ORG/REPO_NAME" in
236-
let env = Arg.env_var "DUNE_RELEASE_OPAM_REPO" in
236+
let env = Cmd.Env.info "DUNE_RELEASE_OPAM_REPO" in
237237
named
238238
(fun x -> `Opam_repo x)
239239
Arg.(
@@ -282,11 +282,11 @@ let setup style_renderer log_level cwd =
282282

283283
let setup =
284284
let style_renderer =
285-
let env = Arg.env_var "DUNE_RELEASE_COLOR" in
285+
let env = Cmd.Env.info "DUNE_RELEASE_COLOR" in
286286
Fmt_cli.style_renderer ~docs:Manpage.s_common_options ~env ()
287287
in
288288
let log_level =
289-
let env = Arg.env_var "DUNE_RELEASE_VERBOSITY" in
289+
let env = Cmd.Env.info "DUNE_RELEASE_VERBOSITY" in
290290
Logs_cli.level ~docs:Manpage.s_common_options ~env ()
291291
in
292292
let cwd =
@@ -299,15 +299,6 @@ let setup =
299299
in
300300
Term.(ret (const setup $ style_renderer $ log_level $ cwd))
301301

302-
(* Verbosity propagation. *)
303-
304-
let propagate_verbosity_to_pkg_file () =
305-
match Logs.level () with
306-
| None -> Cmd.(v "-q")
307-
| Some Logs.Info -> Cmd.(v "-v")
308-
| Some Logs.Debug -> Cmd.(v "-v" % "-v")
309-
| Some _ -> Cmd.empty
310-
311302
(* Error handling *)
312303

313304
let warn_if_vcs_dirty msg =
@@ -329,8 +320,8 @@ let handle_error = function
329320
r
330321

331322
let exits =
332-
Term.exit_info 3 ~doc:"on indiscriminate errors reported on stderr."
333-
:: Term.default_exits
323+
Cmd.Exit.info 3 ~doc:"on indiscriminate errors reported on stderr."
324+
:: Cmd.Exit.defaults
334325

335326
(*---------------------------------------------------------------------------
336327
Copyright (c) 2016 Daniel C. Bünzli

bin/cli.mli

+1-8
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,6 @@ val setup : unit Term.t
116116
side effect, set {!Logs} log verbosity, adjusts colored output and sets the
117117
current working directory. *)
118118

119-
(** {1 Verbosity propagation} *)
120-
121-
val propagate_verbosity_to_pkg_file : unit -> Bos.Cmd.t
122-
(** [propagate_verbosity_to_pkg_file ()] is a command line fragment that has the
123-
option to propagate the current log verbosity to an invocation of the
124-
package description. *)
125-
126119
(** {1 Warnings and errors} *)
127120

128121
val warn_if_vcs_dirty : string -> (unit, R.msg) result
@@ -131,7 +124,7 @@ val warn_if_vcs_dirty : string -> (unit, R.msg) result
131124
val handle_error : (int, R.msg) result -> int
132125
(** [handle_error r] is [r]'s result or logs [r]'s error and returns [3]. *)
133126

134-
val exits : Term.exit_info list
127+
val exits : Cmd.Exit.info list
135128
(** [exits] is are the exit codes common to all commands. *)
136129

137130
(*---------------------------------------------------------------------------

bin/config.ml

+7-6
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ let man =
153153
newly created opam-repository PR or not.";
154154
]
155155

156-
let info =
157-
let doc = "Displays or update dune-release global configuration" in
158-
Cmdliner.Term.info ~doc ~man "config"
159-
160156
let action =
161157
let docv = "ACTION" in
162158
let doc =
@@ -178,5 +174,10 @@ let value =
178174
let doc = "The new field value" in
179175
Cmdliner.Arg.(value & pos 2 (some string) None & info ~doc ~docv [])
180176

181-
let term = Cmdliner.Term.(pure run $ action $ key $ value)
182-
let cmd = (term, info)
177+
let term = Cmdliner.Term.(const run $ action $ key $ value)
178+
179+
let info =
180+
let doc = "Displays or update dune-release global configuration" in
181+
Cmdliner.Cmd.info ~doc ~man "config"
182+
183+
let cmd = Cmdliner.Cmd.v info term

bin/config.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
val cmd : int Cmdliner.Term.t * Cmdliner.Term.info
1+
val cmd : int Cmdliner.Cmd.t

bin/delegate_info.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ let var =
2121
let doc = "The variable to print." in
2222
Arg.(required & pos 0 (some string) None & info [] ~doc ~docv:"VAR")
2323

24-
let term = Term.(pure run $ var)
24+
let term = Term.(const run $ var)
2525

2626
let info =
27-
Term.info "delegate-info" ~doc:"Prints out the given variable to stdout"
27+
Cmd.info "delegate-info" ~doc:"Prints out the given variable to stdout"
2828

29-
let cmd = (term, info)
29+
let cmd = Cmd.v info term

bin/delegate_info.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
val cmd : int Cmdliner.Term.t * Cmdliner.Term.info
1+
val cmd : int Cmdliner.Cmd.t

bin/distrib.ml

+10-8
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ let exits = Cli.exits
7171

7272
let envs =
7373
[
74-
Term.env_info "DUNE_RELEASE_BZIP2"
74+
Cmd.Env.info "DUNE_RELEASE_BZIP2"
7575
~doc:
7676
"The $(b,bzip2) tool to use to compress the\n\
7777
\ archive. Gets the archive on stdin and must output the result on\n\
7878
\ standard out.";
79-
Term.env_info "DUNE_RELEASE_TAR"
79+
Cmd.Env.info "DUNE_RELEASE_TAR"
8080
~doc:
8181
"The $(b,tar) tool to use to unarchive a tbz\n\
8282
\ archive (archive creation itself is handled by dune-release).";
@@ -136,12 +136,14 @@ let man =
136136
relies on bzip2 to be a reproducible function across platforms." );
137137
]
138138

139-
let cmd =
140-
( Term.(
141-
pure distrib_cli $ Cli.setup $ Cli.dry_run $ Cli.build_dir $ Cli.pkg_names
142-
$ Cli.pkg_version $ Cli.dist_tag $ Cli.keep_v $ Cli.keep_build_dir
143-
$ Cli.skip_lint $ Cli.skip_build $ Cli.skip_tests $ Cli.include_submodules),
144-
Term.info "distrib" ~doc ~sdocs ~exits ~envs ~man ~man_xrefs )
139+
let term =
140+
Term.(
141+
const distrib_cli $ Cli.setup $ Cli.dry_run $ Cli.build_dir $ Cli.pkg_names
142+
$ Cli.pkg_version $ Cli.dist_tag $ Cli.keep_v $ Cli.keep_build_dir
143+
$ Cli.skip_lint $ Cli.skip_build $ Cli.skip_tests $ Cli.include_submodules)
144+
145+
let info = Cmd.info "distrib" ~doc ~sdocs ~exits ~envs ~man ~man_xrefs
146+
let cmd = Cmd.v info term
145147

146148
(*---------------------------------------------------------------------------
147149
Copyright (c) 2016 Daniel C. Bünzli

bin/distrib.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ val distrib :
3737

3838
(** The [distrib] command. *)
3939

40-
val cmd : int Cmdliner.Term.t * Cmdliner.Term.info
40+
val cmd : int Cmdliner.Cmd.t
4141

4242
(*---------------------------------------------------------------------------
4343
Copyright (c) 2016 Daniel C. Bünzli

bin/help.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,9 @@ let man =
445445
`P "Use `topics' as $(i,TOPIC) to get a list of topics.";
446446
]
447447

448-
let cmd =
449-
( Term.(ret (const help $ Term.man_format $ topic $ Term.choice_names)),
450-
Term.info "help" ~doc ~exits ~man ~man_xrefs )
448+
let term = Term.(ret (const help $ Arg.man_format $ topic $ Term.choice_names))
449+
let info = Cmd.info "help" ~doc ~exits ~man ~man_xrefs
450+
let cmd = Cmd.v info term
451451

452452
(*---------------------------------------------------------------------------
453453
Copyright (c) 2016 Daniel C. Bünzli

bin/help.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
(** The [help] command. *)
88

9-
val cmd : int Cmdliner.Term.t * Cmdliner.Term.info
9+
val cmd : int Cmdliner.Cmd.t
1010

1111
(*---------------------------------------------------------------------------
1212
Copyright (c) 2016 Daniel C. Bünzli

bin/lint.ml

+8-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ let lints =
3535

3636
let doc = "Check package distribution consistency and conventions"
3737
let sdocs = Manpage.s_common_options
38-
let exits = Term.exit_info 1 ~doc:"on lint failure" :: Cli.exits
38+
let exits = Cmd.Exit.info 1 ~doc:"on lint failure" :: Cli.exits
3939
let man_xrefs = [ `Main; `Cmd "distrib" ]
4040

4141
let man =
@@ -52,11 +52,13 @@ let man =
5252
dune-release-distrib(1) for more details.";
5353
]
5454

55-
let cmd =
56-
( Term.(
57-
pure lint $ Cli.setup $ Cli.dry_run $ Cli.pkg_names $ Cli.pkg_version
58-
$ Cli.dist_tag $ Cli.keep_v $ lints),
59-
Term.info "lint" ~doc ~sdocs ~exits ~man ~man_xrefs )
55+
let term =
56+
Term.(
57+
const lint $ Cli.setup $ Cli.dry_run $ Cli.pkg_names $ Cli.pkg_version
58+
$ Cli.dist_tag $ Cli.keep_v $ lints)
59+
60+
let info = Cmd.info "lint" ~doc ~sdocs ~exits ~man ~man_xrefs
61+
let cmd = Cmd.v info term
6062

6163
(*---------------------------------------------------------------------------
6264
Copyright (c) 2016 Daniel C. Bünzli

bin/lint.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
(** The [lint] command. *)
88

9-
val cmd : int Cmdliner.Term.t * Cmdliner.Term.info
9+
val cmd : int Cmdliner.Cmd.t
1010

1111
(*---------------------------------------------------------------------------
1212
Copyright (c) 2016 Daniel C. Bünzli

bin/main.ml

+4-3
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ let man =
4646
]
4747

4848
let main =
49-
( fst Bistro.cmd,
50-
Term.info "dune-release" ~version:"%%VERSION%%" ~doc ~sdocs ~exits ~man )
49+
Cmd.group ~default:Bistro.term
50+
(Cmd.info "dune-release" ~version:"%%VERSION%%" ~doc ~sdocs ~exits ~man)
51+
cmds
5152

52-
let main () = Term.(exit_status @@ eval_choice main cmds)
53+
let main () = Stdlib.exit @@ Cmd.eval' main
5354
let () = main ()
5455

5556
(*---------------------------------------------------------------------------

bin/opam.ml

+12-12
Original file line numberDiff line numberDiff line change
@@ -399,18 +399,18 @@ let man =
399399
"outputs the field $(i,FIELD) of the package's opam file." );
400400
]
401401

402-
let cmd =
403-
let info = Term.info "opam" ~doc ~sdocs ~envs ~man ~man_xrefs in
404-
let t =
405-
Term.(
406-
pure opam_cli $ Cli.setup $ Cli.dry_run $ Cli.build_dir $ Cli.local_repo
407-
$ Cli.remote_repo $ Cli.opam_repo $ Cli.user $ Cli.keep_v $ Cli.dist_opam
408-
$ Cli.dist_uri $ Cli.dist_file $ Cli.dist_tag $ Cli.pkg_names
409-
$ Cli.pkg_version $ pkg_descr $ Cli.readme $ Cli.change_log
410-
$ Cli.publish_msg $ action $ field_arg $ Cli.no_auto_open $ Cli.yes
411-
$ Cli.token $ Cli.draft)
412-
in
413-
(t, info)
402+
let info = Cmd.info "opam" ~doc ~sdocs ~envs ~man ~man_xrefs
403+
404+
let term =
405+
Term.(
406+
const opam_cli $ Cli.setup $ Cli.dry_run $ Cli.build_dir $ Cli.local_repo
407+
$ Cli.remote_repo $ Cli.opam_repo $ Cli.user $ Cli.keep_v $ Cli.dist_opam
408+
$ Cli.dist_uri $ Cli.dist_file $ Cli.dist_tag $ Cli.pkg_names
409+
$ Cli.pkg_version $ pkg_descr $ Cli.readme $ Cli.change_log
410+
$ Cli.publish_msg $ action $ field_arg $ Cli.no_auto_open $ Cli.yes
411+
$ Cli.token $ Cli.draft)
412+
413+
let cmd = Cmd.v info term
414414

415415
(*---------------------------------------------------------------------------
416416
Copyright (c) 2016 Daniel C. Bünzli

bin/opam.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ val field :
6969

7070
(** The [opam] command. *)
7171

72-
val cmd : int Cmdliner.Term.t * Cmdliner.Term.info
72+
val cmd : int Cmdliner.Cmd.t
7373

7474
(*---------------------------------------------------------------------------
7575
Copyright (c) 2016 Daniel C. Bünzli

0 commit comments

Comments
 (0)