Repository navigation
Update vendored cmdliner to 2.1.1 - #14636
Conversation
| ( | ||
| cd $TMP | ||
| git clone https://github.com/ocaml-dune/cmdliner.git | ||
| git clone https://github.com/ElectreAAS/dune-cmdliner.git |
There was a problem hiding this comment.
Did you do (cd vendor/ && ./update-cmdliner.sh) to check that the script still works and leaves no diff?
There was a problem hiding this comment.
This script will not work as-is. You need to add a second argument to git clone and name the target directory cmdliner, otherwise it will create dune-cmdliner.
There was a problem hiding this comment.
I checked now, and with a simple mv it works.
The call to dune subst (which was unique in the vendor scripts) was removed as it failed with
Error: There is no dune-project file in the current directory, please add one
with a (name <name>) field in it.
Hint: 'dune subst' must be executed from the root of the project.
There was a problem hiding this comment.
Can we keep this on https://github.com/ocaml-dune/cmdliner ? Pulling in specific contributors forks when we have a shared community source seems like unnecessary fragmentation.
| | Error err -> err::errs,args | ||
| let cline = Cmdliner_def.Cline.add arg_info arg cline in | ||
| let errs, args = | ||
| match Cmdliner_def.Arg_info.alias arg_info name value with |
There was a problem hiding this comment.
| match Cmdliner_def.Arg_info.alias arg_info name value with | |
| if for_completion then errs, args | |
| else match Cmdliner_def.Arg_info.alias arg_info name value with |
We probably don't want to expand these when doing completion.
It doesn't have to be in this PR, but I thought I'd point it out anyway.
5935221 to
779b86d
Compare
|
What happened to the benchmarks? Do we have tests that show that we can still use abbreviated command names? |
They are having a bad day today. They will resolve themselves soon.
Yes, this is the main change between 2.0 and 2.1. A mechanism to support the old prefixes was added. These are all exercised in the |
We do have some, but only by (I assume) accident:
We may have others depending on typos. If you think they'd be needed with this PR I'll add a few that specifically test for this |
|
@rgrinberg Here are the patches on the newer cmdliner that we will maintain from now on: dbuenzli/cmdliner@master...ElectreAAS:dune-cmdliner:push-rtpovsrrqquv in |
|
The |
shonfeder
left a comment
There was a problem hiding this comment.
Just a few requests here for readability and clear comments.
Nice work on this change!
| (OCAML_COLOR always)) | ||
| (OCAML_COLOR always) | ||
| ;; Cmdliner 2.0 uses colors. With this option we have quotes like before. | ||
| (NO_COLOR 1)) |
There was a problem hiding this comment.
If I understood correctly, cmdliner 2.x enables color by default, which means the average Dune user would see colors in all cmdliner outputs within Dune. Is this still the recommended way to disable color? In that case, should we document this in Dune docs?
There was a problem hiding this comment.
Actually we have a few colour variables in dune itself. We could probably tie these together. This seems like a sensible follow up PR with a documentation effort too.
There was a problem hiding this comment.
Good point.
I think we don't need to expose the cmdliner-specific NO_COLOR, as it's a kind of implementation detail.
However we maybe should pick up the variable's value in our own color handling code.
Which now that I've checked, we don't have any doc on how to do this, or did I miss it?
There was a problem hiding this comment.
@ElectreAAS We probably don't have any documentation in the manual, but dune build --help does mention CLICOLOR.
779b86d to
64cc66a
Compare
Signed-off-by: Ambre Austen Suhamy <[email protected]>
Signed-off-by: Ambre Austen Suhamy <[email protected]>
64cc66a to
5d2efea
Compare
Signed-off-by: Ambre Austen Suhamy <[email protected]>
Signed-off-by: Ambre Austen Suhamy <[email protected]>
Signed-off-by: Ambre Austen Suhamy <[email protected]>
Signed-off-by: Ambre Austen Suhamy <[email protected]>
5d2efea to
ceebc6d
Compare
|
I've pushed new comments to answer reviews. |
|
@ElectreAAS Did you sync your fork with the new changes? |
shonfeder
left a comment
There was a problem hiding this comment.
I think we should keep basing this out of ocaml-dune/cmdliner, but otherwise looks fine and I wouldn't insist if others object to that suggestion.
| ( | ||
| cd $TMP | ||
| git clone https://github.com/ocaml-dune/cmdliner.git | ||
| git clone https://github.com/ElectreAAS/dune-cmdliner.git |
There was a problem hiding this comment.
Can we keep this on https://github.com/ocaml-dune/cmdliner ? Pulling in specific contributors forks when we have a shared community source seems like unnecessary fragmentation.
| `dune bui` as a shorthand for `dune build`. This feature was mostly deleted | ||
| in cmdliner 2.0, with a backdoor allowing these 'legacy prefixes' below. | ||
| Since we make use of these prefixes in dune, we always allow them. | ||
| See also https://github.com/ocaml/dune/issues/12515#issuecomment-3802602856 |
Yep that was always the goal, the fork was put there to make sure the update script did indeed produce the same code as what's in this PR |
|
As this has been approved, I'll go ahead and start the merge process
|
Signed-off-by: Ambre Austen Suhamy <[email protected]>
Follow-up to #14636, which bumped the version of cmdliner to 2.1.1 This version bump allows us to use the command completion features of cmdliner for supported shells: `bash`, `zsh`, and `powershell`. ### What is included For supported shells - (sub)command completion: `dune b<tab> -> dune build` - (sub)command suggestion `dune init <tab> -> executable library ...` - flag completion & suggestion `dune build --pro <tab> -> --profile --promote-install-files` ### What is NOT included - Target completion `dune build <tab> -> @test @install ...`. The code infrastructure for this isn't present in dune yet, from what I understand it'd be a significant undertaking. - Completion for fish 🐟 😢 ### Experimental testing I was only able to test that this works in bash on my machine, reviewer help for zsh and more importantly powershell would be welcome. To test this PR: - For bash ([you might need this first](https://github.com/scop/bash-completion)), either run `dune completion bash > ~/.local/share/bash-completion/completions/dune`, or add `eval "$(dune completion bash)"` to your bashrc - For zsh ([you might need this first](https://github.com/zsh-users/zsh-completions)), run `dune completion zsh > ~/.local/share/zsh/site-functions/_dune`, and make sure that directory is in your `$fpath`: you might need to add `fpath+=~/.local/share/zsh/site-functions` to your .zshrc before `compinit`. - For powershell, either run `dune completion pwsh >> $PROFILE.CurrentUserCurrentHost` or add `Invoke-Expression -Command $(dune completion pwsh | Out-String)` to your profile script You should be able to see completions! ### Thanks All my thanks to `The cmdliner programmers` whose work made this possible. @dbuenzli & @WardBrian ❤️ --------- Signed-off-by: Ambre Austen Suhamy <[email protected]>
Fixes #12515.
This PR pulls in all the changes from cmdliner 2.1.1, see changelog here.
Among these changes, there are new error messages formats, so that's a big diff on that commit.
On top of the released cmdliner, there is a singular patch to keep support for aliases.
This has the non-insignificant bonus of simplifying maintenance of our fork over at https://github.com/ocaml-dune/cmdliner