Skip to content

Commit a849f79

Browse files
authored
Merge pull request #3936 from rgrinberg/ocaml-command
Introduce `dune ocaml` command group
2 parents 7c2cb79 + a14a9f1 commit a849f79

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+359
-135
lines changed

CHANGES.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Unreleased
77
- Fixed a bug that could result in needless recompilation under Windows due to
88
case differences in the result of `Sys.getcwd` (observed under `emacs`).
99
(#3966, @nojb).
10-
10+
1111
- Fixed absence of executable bit for installed `.cmxs` (#4149, fixes #4148, @bobot)
1212

1313
- Allow `%{version:pkg}` to work for external packages (#4104, @kit-ty-kate)
@@ -17,6 +17,9 @@ Unreleased
1717
- Automatically generate empty `.mli` files for executables and tests (#3768,
1818
fixes #3745, @CraigFe)
1919

20+
- Add `ocaml` command subgroup for OCaml related commands such as `utop`, `top`,
21+
and `merlin` (#3936, @rgrinberg).
22+
2023
2.8.2 (21/01/2021)
2124
------------------
2225

bin/import.ml

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ module Profile = Dune_rules.Profile
2929
module Log = Dune_util.Log
3030
include Common.Let_syntax
3131

32+
let in_group (t, info) = (Term.Group.Term t, info)
33+
3234
let make_cache (config : Config.t) =
3335
let make_cache () =
3436
let command_handler (Cache.Dedup file) =

bin/main.ml

+31-26
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
11
open! Stdune
22
open Import
33

4-
let all =
5-
[ Installed_libraries.command
6-
; External_lib_deps.command
7-
; Build_cmd.build
8-
; Build_cmd.runtest
9-
; command_alias Build_cmd.runtest "test"
10-
; Clean.command
11-
; Install_uninstall.install
12-
; Install_uninstall.uninstall
13-
; Exec.command
14-
; Subst.command
15-
; Print_rules.command
16-
; Utop.command
17-
; Init.command
18-
; Promote.command
19-
; Printenv.command
20-
; Help.command
21-
; Format_dune_file.command
22-
; Compute.command
23-
; Upgrade.command
24-
; Caching.command
25-
; Describe.command
26-
; Top.command
27-
; Ocaml_merlin.command
28-
]
4+
let all : _ Term.Group.t list =
5+
let terms =
6+
[ Installed_libraries.command
7+
; External_lib_deps.command
8+
; Build_cmd.build
9+
; Build_cmd.runtest
10+
; command_alias Build_cmd.runtest "test"
11+
; Clean.command
12+
; Install_uninstall.install
13+
; Install_uninstall.uninstall
14+
; Exec.command
15+
; Subst.command
16+
; Print_rules.command
17+
; Utop.command
18+
; Init.command
19+
; Promote.command
20+
; Printenv.command
21+
; Help.command
22+
; Format_dune_file.command
23+
; Compute.command
24+
; Upgrade.command
25+
; Caching.command
26+
; Describe.command
27+
; Top.command
28+
; Ocaml_merlin.command
29+
]
30+
|> List.map ~f:in_group
31+
in
32+
let groups = [ Ocaml.group ] in
33+
terms @ groups
2934

3035
let common_commands_synopsis =
3136
(* Short reminders for the most used and useful commands *)
@@ -88,7 +93,7 @@ let default =
8893
let () =
8994
Colors.setup_err_formatter_colors ();
9095
try
91-
match Term.eval_choice default all ~catch:false with
96+
match Term.Group.eval default all ~catch:false with
9297
| `Error _ -> exit 1
9398
| _ -> exit 0
9499
with exn ->

bin/ocaml.ml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
open Import
2+
3+
let info = Term.info "ocaml"
4+
5+
let group =
6+
( Term.Group.Group
7+
[ in_group Utop.command
8+
; in_group Ocaml_merlin.command
9+
; in_group Top.command
10+
]
11+
, info )

bin/ocaml.mli

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
open Import
2+
3+
val group : unit Term.Group.t

bin/top.mli

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
val command : unit Cmdliner.Term.t * Cmdliner.Term.info

doc/dune.inc

+18-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11

2+
(rule
3+
(with-stdout-to dune-test.1
4+
(run dune test --help=groff)))
5+
6+
(install
7+
(section man)
8+
(package dune)
9+
(files dune-test.1))
10+
211
(rule
312
(with-stdout-to dune-build.1
413
(run dune build --help=groff)))
@@ -107,6 +116,15 @@
107116
(package dune)
108117
(files dune-installed-libraries.1))
109118

119+
(rule
120+
(with-stdout-to dune-ocaml.1
121+
(run dune ocaml --help=groff)))
122+
123+
(install
124+
(section man)
125+
(package dune)
126+
(files dune-ocaml.1))
127+
110128
(rule
111129
(with-stdout-to dune-ocaml-merlin.1
112130
(run dune ocaml-merlin --help=groff)))
@@ -197,12 +215,3 @@
197215
(package dune)
198216
(files dune-utop.1))
199217

200-
(rule
201-
(with-stdout-to dune-test.1
202-
(run dune test --help=groff)))
203-
204-
(install
205-
(section man)
206-
(package dune)
207-
(files dune-test.1))
208-

doc/toplevel-integration.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ simply execute the following in your toplevel:
1313

1414
.. code:: ocaml
1515
16-
# #use_output "dune top";;
16+
# #use_output "dune ocaml top";;
1717
18-
``dune top`` is a dune command that builds all the libraries in the
18+
``dune ocaml top`` is a dune command that builds all the libraries in the
1919
current directory and sub-directories and output the relevant toplevel
2020
directives (``#directory`` and ``#load``) to make the various modules
2121
available in the toplevel.
@@ -25,9 +25,9 @@ you type in the toplevel will be rewritten with these ppx rewriters.
2525

2626
This command is available since Dune 2.5.0.
2727

28-
Note that the ``#use_output`` directivce is only available since OCaml
29-
4.11. You can add the following snippet to your ``~/.ocamlinit`` file
30-
to make it available in older versions of OCaml:
28+
Note that the ``#use_output`` directive is only available since OCaml 4.11. You
29+
can add the following snippet to your ``~/.ocamlinit`` file to make it available
30+
in older versions of OCaml:
3131

3232
.. code:: ocaml
3333

doc/update-jbuild.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
set -e -o pipefail
66

77
CMDS=$(dune --help=plain | \
8-
sed -n '/COMMANDS/,/OPTIONS/p' | sed -En 's/^ ([a-z-]+) ?.*/\1/p')
8+
sed -n '/COMMAND ALIASES/,/OPTIONS/p' | sed -En 's/^ ([a-z-]+) ?.*/\1/p')
99

1010
for cmd in $CMDS; do
1111
cat <<EOF

test/blackbox-tests/test-cases/cmdliner-dep-conf.t/run.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
[1]
1515

1616
$ dune build "(fi"
17-
dune: TARGET... arguments: unclosed parenthesis at end of input
17+
dune build: TARGET... arguments: unclosed parenthesis at end of input
1818
Usage: dune build [OPTION]... [TARGET]...
1919
Try `dune build --help' or `dune --help' for more information.
2020
[1]
2121

2222
$ dune build "()"
23-
dune: TARGET... arguments: Unexpected list
23+
dune build: TARGET... arguments: Unexpected list
2424
Usage: dune build [OPTION]... [TARGET]...
2525
Try `dune build --help' or `dune --help' for more information.
2626
[1]

test/blackbox-tests/test-cases/describe.t/run.t

+4-4
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ Test errors
9494
[1]
9595

9696
$ dune describe --lang 1.0
97-
dune: Only --lang 0.1 is available at the moment as this command is not yet
98-
stabilised. If you would like to release a software that relies on the output
99-
of 'dune describe', please open a ticket on
100-
https://github.com/ocaml/dune.
97+
dune describe: Only --lang 0.1 is available at the moment as this command is not yet
98+
stabilised. If you would like to release a software that relies on the output
99+
of 'dune describe', please open a ticket on
100+
https://github.com/ocaml/dune.
101101
Usage: dune describe [OPTION]... [STRING]...
102102
Try `dune describe --help' or `dune --help' for more information.
103103
[1]

test/blackbox-tests/test-cases/dune-init.t/run.t

+7-6
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,11 @@ Comments in dune files are preserved
239239
Will not create components with invalid names
240240

241241
$ dune init lib invalid-component-name ./_test_lib
242-
dune: NAME argument: invalid component name `invalid-component-name'
243-
Library names must be non-empty and composed only of the
244-
following
245-
characters: 'A'..'Z', 'a'..'z', '_' or '0'..'9'.
242+
dune init: NAME argument: invalid component name
243+
`invalid-component-name'
244+
Library names must be non-empty and composed only of the
245+
following
246+
characters: 'A'..'Z', 'a'..'z', '_' or '0'..'9'.
246247
Usage: dune init [OPTION]... INIT_KIND NAME [PATH]
247248
Try `dune init --help' or `dune --help' for more information.
248249
[1]
@@ -252,8 +253,8 @@ Will not create components with invalid names
252253
Will fail and inform user when invalid component command is given
253254

254255
$ dune init foo blah
255-
dune: INIT_KIND argument: invalid value `foo', expected one of `executable',
256-
`library', `project' or `test'
256+
dune init: INIT_KIND argument: invalid value `foo', expected one of
257+
`executable', `library', `project' or `test'
257258
Usage: dune init [OPTION]... INIT_KIND NAME [PATH]
258259
Try `dune init --help' or `dune --help' for more information.
259260
[1]

test/blackbox-tests/test-cases/findlib-dynload.t/run.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@
5151
b: called
5252
a: called
5353

54-
$ dune exe mytool_auto
54+
$ dune exec mytool_auto
5555
m: init
5656
a: init
5757
b: init
5858
b: registering
5959
b: called
6060
a: called
6161

62-
$ dune exe mytool c_thread
62+
$ dune exec mytool c_thread
6363
m: init
6464
c_thread: registering
6565

test/blackbox-tests/test-cases/format-dune-file.t/run.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ Files in OCaml syntax are copied verbatim (but error when passed in stdin).
171171
172172
Non 0 error code:
173173
174-
$ echo "(" | dune format ; echo $?
174+
$ echo "(" | dune format-dune-file ; echo $?
175175
File "", line 2, characters 0-0:
176176
Error: unclosed parenthesis at end of input
177177
1

test/blackbox-tests/test-cases/github3046.t/run.t

+9-8
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,29 @@ are given as parameters
77
`dune init exe main --libs="str gsl"` returns an informative parsing error
88

99
$ dune init exe main --libs="str gsl"
10-
dune: option `--libs': invalid element in list (`str gsl'): expected a valid
11-
dune atom
10+
dune init: option `--libs': invalid element in list (`str gsl'): expected a
11+
valid dune atom
1212
Usage: dune init [OPTION]... INIT_KIND NAME [PATH]
1313
Try `dune init --help' or `dune --help' for more information.
1414
[1]
1515

1616
`dune init lib foo --ppx="foo bar"` returns an informative parsing error
1717

1818
$ dune init lib foo --ppx="foo bar"
19-
dune: option `--ppx': invalid element in list (`foo bar'): expected a valid
20-
dune atom
19+
dune init: option `--ppx': invalid element in list (`foo bar'): expected a
20+
valid dune atom
2121
Usage: dune init [OPTION]... INIT_KIND NAME [PATH]
2222
Try `dune init --help' or `dune --help' for more information.
2323
[1]
2424

2525
`dune init lib foo --public="some/invalid&name!"` returns an informative parsing error
2626

2727
$ dune init lib foo --public="some/invalid&name!"
28-
dune: option `--public': invalid component name `some/invalid&name!'
29-
Library names must be non-empty and composed only of the
30-
following
31-
characters: 'A'..'Z', 'a'..'z', '_' or '0'..'9'.
28+
dune init: option `--public': invalid component name
29+
`some/invalid&name!'
30+
Library names must be non-empty and composed only of the
31+
following
32+
characters: 'A'..'Z', 'a'..'z', '_' or '0'..'9'.
3233
Usage: dune init [OPTION]... INIT_KIND NAME [PATH]
3334
Try `dune init --help' or `dune --help' for more information.
3435
[1]

test/blackbox-tests/test-cases/github3530.t/run.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ When an empty string is passed to `-p`, we get a nice error message.
22

33
$ echo '(lang dune 2.0)' > dune-project
44
$ dune build -p ''
5-
dune: option `-p': Invalid package name: ""
5+
dune build: option `-p': Invalid package name: ""
66
Usage: dune build [OPTION]... [TARGET]...
77
Try `dune build --help' or `dune --help' for more information.
88
[1]
99

1010
This can happen in a list as well:
1111

1212
$ dune build -p 'a,b,'
13-
dune: option `-p': Invalid package name: ""
13+
dune build: option `-p': Invalid package name: ""
1414
Usage: dune build [OPTION]... [TARGET]...
1515
Try `dune build --help' or `dune --help' for more information.
1616
[1]

test/blackbox-tests/test-cases/misc.t/run.t

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,37 @@ Test that incompatible options are properly reported
66
----------------------------------------------------
77

88
$ dune build --verbose --display quiet
9-
dune: Cannot use --verbose and --display simultaneously
9+
dune build: Cannot use --verbose and --display simultaneously
1010
Usage: dune build [OPTION]... [TARGET]...
1111
Try `dune build --help' or `dune --help' for more information.
1212
[1]
1313

1414
$ dune build -p toto --root .
15-
dune: Cannot use --root and -p simultaneously
15+
dune build: Cannot use --root and -p simultaneously
1616
Usage: dune build [OPTION]... [TARGET]...
1717
Try `dune build --help' or `dune --help' for more information.
1818
[1]
1919

2020
$ dune build --for-release-of-packages toto --root .
21-
dune: Cannot use --root and --for-release-of-packages simultaneously
21+
dune build: Cannot use --root and --for-release-of-packages simultaneously
2222
Usage: dune build [OPTION]... [TARGET]...
2323
Try `dune build --help' or `dune --help' for more information.
2424
[1]
2525

2626
$ dune build --no-config --config x
27-
dune: Cannot use --config and --no-config simultaneously
27+
dune build: Cannot use --config and --no-config simultaneously
2828
Usage: dune build [OPTION]... [TARGET]...
2929
Try `dune build --help' or `dune --help' for more information.
3030
[1]
3131

3232
$ dune build -p toto --release
33-
dune: Cannot use --release and -p simultaneously
33+
dune build: Cannot use --release and -p simultaneously
3434
Usage: dune build [OPTION]... [TARGET]...
3535
Try `dune build --help' or `dune --help' for more information.
3636
[1]
3737

3838
$ dune build --release --root .
39-
dune: Cannot use --root and --release simultaneously
39+
dune build: Cannot use --root and --release simultaneously
4040
Usage: dune build [OPTION]... [TARGET]...
4141
Try `dune build --help' or `dune --help' for more information.
4242
[1]

test/blackbox-tests/test-cases/pipe-actions.t/run.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The makefile version of pipe actions uses actual pipes:
5252
> (pipe-outputs (run a) (run b) (run c)))))
5353
> EOF
5454

55-
$ dune rule -m target
55+
$ dune rules -m target
5656
_build/default/target: _build/install/default/bin/a \
5757
_build/install/default/bin/b _build/install/default/bin/c
5858
mkdir -p _build/default; \

0 commit comments

Comments
 (0)