These scripts were generated by modifying Dune to parse command line arguments using the library climate - a library with similar semantics to cmdliner but with the ability to generate completion scripts. This modified version of dune lives on this branch
Interesting! Looks like there are competitors to cmdliner now.
And that reminds me I’ve submitted a draft PR to cmdliner to add completion support some time ago. Hopefully dbuenzli will have some time soon to quickly glance over there
I need to reserve a couple of days to make sure we get that in right. I’m afraid these couple of days are not going to be available before the beginning of next year. People can help by trying the PR and see if the plan there works well for them or suggest what doesn’t if it doesn’t.
Is there any chance that dune test @
may complete me all .t file that are in my directory tree?
or any alias, really. dune build @
It’s definitely a step forward, but I wonder how far this approach will go and how maintainable it will be. Looks like the entire dune command line arguments definition is compiled to lots of bash code. It will work for the static parts of commands (for some fixed version of dune), but can it complete some dynamic parts, e.g. aliases?
Maybe that’s something that needs to be built into dune itself as some kind of special dune complete
command (or perhaps using dune RPC instead?).
I’ve used that approach quite successfully in Goblint to allow completion of any dynamic information as well and the single bash completion script works for all versions of the tool by just delegating to it. (To achieve that, I made a library to extend Stdlib.Arg
, sorry for the shameless plug, but perhaps it’s of use to someone else as well.)
This is a feature I’ve been experimenting with in climate, where the completion script can query the program for completion suggestions (here’s an example). It would require support in dune to provide completion suggestions. I’m planning to experiment with this when I get time.
Any chance to publish climate to opam? ^^
I was actually planning to start the process in the next couple of days!
Cool, let me know I was almost implementing something hacky and having a way to have completion scripts would be massive.
Thanks for the work!