Skip to content

Commit

Permalink
Update cmdliner to display full command name
Browse files Browse the repository at this point in the history
  • Loading branch information
emillon committed Sep 5, 2022
1 parent 0b45bad commit e8b08e7
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 32 deletions.
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/cmdline/profile.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Bug #4632

$ dune build -p
dune: option '-p' needs an argument
dune build: option '-p' needs an argument
Usage: dune build [OPTION]… [TARGET]…
Try 'dune build --help' or 'dune --help' for more information.
[1]
Expand Down
4 changes: 2 additions & 2 deletions test/blackbox-tests/test-cases/cmdliner-dep-conf.t/run.t
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
[1]

$ dune build "(fi"
dune: TARGET… arguments: unclosed parenthesis at end of input
dune build: TARGET… arguments: unclosed parenthesis at end of input
Usage: dune build [OPTION]… [TARGET]…
Try 'dune build --help' or 'dune --help' for more information.
[1]

$ dune build "()"
dune: TARGET… arguments: Unexpected list
dune build: TARGET… arguments: Unexpected list
Usage: dune build [OPTION]… [TARGET]…
Try 'dune build --help' or 'dune --help' for more information.
[1]
8 changes: 4 additions & 4 deletions test/blackbox-tests/test-cases/describe.t
Original file line number Diff line number Diff line change
Expand Up @@ -1267,10 +1267,10 @@ Test errors
[1]

$ dune describe --lang 1.0
dune: Only --lang 0.1 is available at the moment as this command is not yet
stabilised. If you would like to release a software that relies on the output
of 'dune describe', please open a ticket on
https://github.com/ocaml/dune.
dune describe: Only --lang 0.1 is available at the moment as this command is not yet
stabilised. If you would like to release a software that relies on the output
of 'dune describe', please open a ticket on
https://github.com/ocaml/dune.
Usage: dune describe [OPTION]… [STRING]…
Try 'dune describe --help' or 'dune --help' for more information.
[1]
Expand Down
13 changes: 7 additions & 6 deletions test/blackbox-tests/test-cases/dune-init.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,11 @@ Comments in dune files are preserved
Will not create components with invalid names

$ dune init lib invalid-component-name ./_test_lib
dune: NAME argument: invalid component name `invalid-component-name'
Library names must be non-empty and composed only of the
following
characters: 'A'..'Z', 'a'..'z', '_' or '0'..'9'.
dune init: NAME argument: invalid component name
`invalid-component-name'
Library names must be non-empty and composed only of the
following
characters: 'A'..'Z', 'a'..'z', '_' or '0'..'9'.
Usage: dune init [OPTION]… COMPONENT NAME [PATH]
Try 'dune init --help' or 'dune --help' for more information.
[1]
Expand All @@ -264,8 +265,8 @@ Will not create components with invalid names
Will fail and inform user when invalid component command is given

$ dune init foo blah
dune: COMPONENT argument: invalid value 'foo', expected one of 'executable',
'library', 'project' or 'test'
dune init: COMPONENT argument: invalid value 'foo', expected one of
'executable', 'library', 'project' or 'test'
Usage: dune init [OPTION]… COMPONENT NAME [PATH]
Try 'dune init --help' or 'dune --help' for more information.
[1]
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/external-lib-deps.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
external-lib-deps is no more.

$ dune external-lib-deps
dune: This subcommand is no longer implemented.
dune external-lib-deps: This subcommand is no longer implemented.
[1]
17 changes: 9 additions & 8 deletions test/blackbox-tests/test-cases/github3046.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,29 @@ are given as parameters
`dune init exe main --libs="str gsl"` returns an informative parsing error

$ dune init exe main --libs="str gsl"
dune: option '--libs': invalid element in list ('str gsl'): expected a valid
dune atom
dune init: option '--libs': invalid element in list ('str gsl'): expected a
valid dune atom
Usage: dune init [OPTION]… COMPONENT NAME [PATH]
Try 'dune init --help' or 'dune --help' for more information.
[1]

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

$ dune init lib foo --ppx="foo bar"
dune: option '--ppx': invalid element in list ('foo bar'): expected a valid
dune atom
dune init: option '--ppx': invalid element in list ('foo bar'): expected a
valid dune atom
Usage: dune init [OPTION]… COMPONENT NAME [PATH]
Try 'dune init --help' or 'dune --help' for more information.
[1]

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

$ dune init lib foo --public="some/invalid&name!"
dune: option '--public': invalid component name `some/invalid&name!'
Library names must be non-empty and composed only of the
following
characters: 'A'..'Z', 'a'..'z', '_' or '0'..'9'.
dune init: option '--public': invalid component name
`some/invalid&name!'
Library names must be non-empty and composed only of the
following
characters: 'A'..'Z', 'a'..'z', '_' or '0'..'9'.
Usage: dune init [OPTION]… COMPONENT NAME [PATH]
Try 'dune init --help' or 'dune --help' for more information.
[1]
4 changes: 2 additions & 2 deletions test/blackbox-tests/test-cases/github3530.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ When an empty string is passed to `-p`, we get a nice error message.

$ echo '(lang dune 2.0)' > dune-project
$ dune build -p ''
dune: option '--only-packages': Invalid package name: ""
dune build: option '--only-packages': Invalid package name: ""
Usage: dune build [OPTION]… [TARGET]…
Try 'dune build --help' or 'dune --help' for more information.
[1]

This can happen in a list as well:

$ dune build -p 'a,b,'
dune: option '--only-packages': Invalid package name: ""
dune build: option '--only-packages': Invalid package name: ""
Usage: dune build [OPTION]… [TARGET]…
Try 'dune build --help' or 'dune --help' for more information.
[1]
12 changes: 6 additions & 6 deletions test/blackbox-tests/test-cases/misc.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,37 @@ Test that incompatible options are properly reported
----------------------------------------------------

$ dune build --verbose --display quiet
dune: Cannot use --verbose and --display simultaneously
dune build: Cannot use --verbose and --display simultaneously
Usage: dune build [OPTION]… [TARGET]…
Try 'dune build --help' or 'dune --help' for more information.
[1]

$ dune build -p toto --root .
dune: option '--root' cannot be repeated
dune build: option '--root' cannot be repeated
Usage: dune build [OPTION]… [TARGET]…
Try 'dune build --help' or 'dune --help' for more information.
[1]

$ dune build --for-release-of-packages toto --root .
dune: option '--root' cannot be repeated
dune build: option '--root' cannot be repeated
Usage: dune build [OPTION]… [TARGET]…
Try 'dune build --help' or 'dune --help' for more information.
[1]

$ dune build --no-config --config x
dune: Cannot use --config and --no-config simultaneously
dune build: Cannot use --config and --no-config simultaneously
Usage: dune build [OPTION]… [TARGET]…
Try 'dune build --help' or 'dune --help' for more information.
[1]

$ dune build -p toto --release
dune: option '--root' cannot be repeated
dune build: option '--root' cannot be repeated
Usage: dune build [OPTION]… [TARGET]…
Try 'dune build --help' or 'dune --help' for more information.
[1]

$ dune build --release --root .
dune: option '--root' cannot be repeated
dune build: option '--root' cannot be repeated
Usage: dune build [OPTION]… [TARGET]…
Try 'dune build --help' or 'dune --help' for more information.
[1]
Expand Down
4 changes: 4 additions & 0 deletions vendor/cmdliner/src/cmdliner.mli
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,10 @@ module Cmd : sig
(** {1:info Environment variable information} *)

[@@@alert "-deprecated"]

type info = Term.env_info (* because of Arg. *)
(** The type for environment variable information. *)

[@@@alert "+deprecated"]

val info : ?deprecated:string -> ?docs:string -> ?doc:string -> var -> info
Expand Down Expand Up @@ -799,11 +801,13 @@ module Arg : sig
(** The type for converted argument printers. *)

[@@@alert "-deprecated"] (* Need to be able to mention them ! *)

type 'a conv = 'a parser * 'a printer
(** The type for argument converters.
{b Warning.} Do not use directly, use {!val-conv} or {!val-conv'}.
This type will become abstract in the next major version of cmdliner. *)

[@@@alert "+deprecated"] (* Need to be able to mention them ! *)

val conv :
Expand Down
5 changes: 4 additions & 1 deletion vendor/cmdliner/src/cmdliner_msg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ let err_cmd_missing ~dom =

(* Other messages *)

let exec_name ei = Cmdliner_info.Cmd.name @@ Cmdliner_info.Eval.main ei
let exec_name ei =
let cmd = Cmdliner_info.Eval.cmd ei in
let parents = Cmdliner_info.Eval.parents ei in
String.concat " " @@ List.rev_map Cmdliner_info.Cmd.name @@ cmd::parents

let pp_version ppf ei =
match Cmdliner_info.Cmd.version @@ Cmdliner_info.Eval.main ei with
Expand Down
2 changes: 1 addition & 1 deletion vendor/update-cmdliner.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

version=37a715a37393516860a58d8ac6d38ac9bc5d7c96
version=7b1940f6c5fdd85189bed10a12068d1f756e01c3

set -e -o pipefail

Expand Down

0 comments on commit e8b08e7

Please sign in to comment.