Skip to content

Commit 18481d8

Browse files
Update to Cmdliner 1.1.0
Cmdliner 1.1.0 changed a number of things in its API and deprecated the old way, so to be forward compatible we upgrade our dependency and start using Cmdliner the new way.
1 parent 765010b commit 18481d8

File tree

15 files changed

+62
-65
lines changed

15 files changed

+62
-65
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#### Fixed
1010

11+
- Fixed compatibility with Cmdliner 1.1.0 (#371, @Leonidas-from-XIV)
12+
1113
#### Removed
1214

1315
#### Security

bin/cli.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let named wrapper = Term.(app (const wrapper))
55

66
let non_deterministic =
77
let doc = "Run non-deterministic tests." in
8-
let env = Arg.env_var ~doc "MDX_RUN_NON_DETERMINISTIC" in
8+
let env = Cmd.Env.info ~doc "MDX_RUN_NON_DETERMINISTIC" in
99
named
1010
(fun x -> `Non_deterministic x)
1111
Arg.(value & flag & info [ "non-deterministic"; "n" ] ~env ~doc)

bin/deps.ml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ let run (`Setup ()) (`Syntax syntax) (`File file) =
3333
Printf.printf "%s" (Mdx.Util.Csexp.to_string (List deps));
3434
0
3535

36-
let cmd =
37-
let open Cmdliner in
38-
let doc =
39-
"List the dependencies of the input file. This command is meant to be used \
40-
by dune only. There are no stability guarantees."
41-
in
42-
(Term.(pure run $ Cli.setup $ Cli.syntax $ Cli.file), Term.info "deps" ~doc)
36+
let term = Cmdliner.Term.(const run $ Cli.setup $ Cli.syntax $ Cli.file)
37+
38+
let doc =
39+
"List the dependencies of the input file. This command is meant to be used \
40+
by dune only. There are no stability guarantees."
41+
42+
let info = Cmdliner.Cmd.info "deps" ~doc
43+
let cmd = Cmdliner.Cmd.v info term

bin/deps.mli

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,4 @@
1414
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1515
*)
1616

17-
open Cmdliner
18-
19-
val cmd : int Term.t * Term.info
17+
val cmd : int Cmdliner.Cmd.t

bin/dune_gen.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ let run (`Setup ()) (`Prelude prelude) (`Directories dirs) =
5656
Buffer.output_buffer stdout buffer;
5757
0
5858

59-
let cmd =
60-
let open Cmdliner in
61-
let doc =
62-
"Generate the source for a specialized testing binary. This command is \
63-
meant to be used by dune only. There are no stability guarantees."
64-
in
65-
( Term.(pure run $ Cli.setup $ Cli.prelude $ Cli.directories),
66-
Term.info "dune-gen" ~doc )
59+
let term = Cmdliner.Term.(const run $ Cli.setup $ Cli.prelude $ Cli.directories)
60+
61+
let doc =
62+
"Generate the source for a specialized testing binary. This command is meant \
63+
to be used by dune only. There are no stability guarantees."
64+
65+
let info = Cmdliner.Cmd.info "dune-gen" ~doc
66+
let cmd = Cmdliner.Cmd.v info term

bin/dune_gen.mli

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,4 @@
1414
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1515
*)
1616

17-
open Cmdliner
18-
19-
val cmd : int Term.t * Term.info
17+
val cmd : int Cmdliner.Cmd.t

bin/main.ml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717
open Cmdliner
1818

1919
let cmds = [ Test.cmd; Pp.cmd; Deps.cmd; Dune_gen.cmd ]
20-
let main (`Setup ()) = `Help (`Pager, None)
2120

2221
let main =
2322
let doc = "Execute markdown files." in
24-
let exits = Term.default_exits in
2523
let man = [] in
26-
( Term.(ret (const main $ Cli.setup)),
27-
Term.info "ocaml-mdx" ~version:"%%VERSION%%" ~doc ~exits ~man )
24+
Cmd.info "ocaml-mdx" ~version:"%%VERSION%%" ~doc ~man
2825

29-
let () = Term.(exit_status @@ eval_choice main cmds)
26+
let group = Cmd.group main cmds
27+
let () = Stdlib.exit @@ Cmd.eval' group

bin/pp.ml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ let run (`Setup ()) (`File file) (`Section section) =
6262

6363
open Cmdliner
6464

65-
let cmd =
66-
let doc = "Pre-process markdown files to produce OCaml code." in
67-
let exits = Term.default_exits in
68-
( Term.(pure run $ Cli.setup $ Cli.file $ Cli.section),
69-
Term.info "pp" ~doc ~exits )
65+
let term = Term.(const run $ Cli.setup $ Cli.file $ Cli.section)
66+
let doc = "Pre-process markdown files to produce OCaml code."
67+
let info = Cmd.info "pp" ~doc
68+
let cmd = Cmd.v info term

bin/pp.mli

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,4 @@
1414
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1515
*)
1616

17-
open Cmdliner
18-
19-
val cmd : int Term.t * Term.info
17+
val cmd : int Cmdliner.Cmd.t

bin/test.ml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ let run (`Setup ()) _ _ _ _ _ _ _ _ _ _ =
4747

4848
open Cmdliner
4949

50-
let cmd : int Term.t * Term.info =
51-
let doc = "Test markdown files." in
52-
( Term.(
53-
pure run $ Cli.setup $ Cli.non_deterministic $ Cli.silent_eval
54-
$ Cli.syntax $ Cli.silent $ Cli.verbose_findlib $ Cli.prelude
55-
$ Cli.prelude_str $ Cli.file $ Cli.section $ Cli.root $ Cli.force_output
56-
$ Cli.output),
57-
Term.info "test" ~doc )
50+
let term =
51+
Term.(
52+
const run $ Cli.setup $ Cli.non_deterministic $ Cli.silent_eval $ Cli.syntax
53+
$ Cli.silent $ Cli.verbose_findlib $ Cli.prelude $ Cli.prelude_str
54+
$ Cli.file $ Cli.section $ Cli.root $ Cli.force_output $ Cli.output)
55+
56+
let doc = "Test markdown files."
57+
let info = Cmd.info "test" ~doc
58+
let cmd = Cmd.v info term

0 commit comments

Comments
 (0)