Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: dune build@alias <paths> to help with globbing and file-completion #4537

Open
raphael-proust opened this issue Apr 28, 2021 · 6 comments
Labels
feature-request User wanted features

Comments

@raphael-proust
Copy link
Contributor

Desired Behavior

I want to be able to use globing and shell auto-completion on files, even when building aliases.

E.g., I can currently use dune runtest src/lib_* but I cannot use dune build @src/lib_*/check

Example

Currently I cannot do dune build @src/lib_*/check because the @ and the check are part of the "path". Additionally I cannot tab complete on long paths because the @ at the beginning makes the shell interpret things not as path.

How about allowing the form dune build@<alias> <paths>? E.g.,

dune build@check src/lib_*
dune build@install src/core/v1/server

Note, this would render dune runtest and dune build@runtest equivalent, and in fact it would generalise the use of dune runtest as a command that accepts any set of paths.

@ghost
Copy link

ghost commented Apr 28, 2021

I want to be able to use globing and shell auto-completion on files, even when building aliases.

I had exactly the same thought yesterday while I was testing dune with Jane Street code base.

I personally like the proposal. Having proper support for completion in the Dune cli would be another way to improve the user experience, but this proposal is simpler and would work all the time.

I'm forwarding it to other Dune devs for discussion.

@ghost
Copy link

ghost commented May 5, 2021

We discussed the proposal in today's meeting. We agree on the issue, but overall we are not too keen on the proposed solution. Among other reasons, it adds one more way to do the same thing and doesn't work when one wants to build multiple targets.

Additionally, proper shell completion seems like a more general solution to this problem and doesn't require introducing a new syntax that users will have to learn. So for now we'd like to wait until we have shell completion. Once we have it, we can revisit this proposal if it still feels needed.

BTW, I just updated the feature request for better shell competion to mention that we are now using a fork of cmdliner. This means that it should be easier to add shell completion to Dune this way.

@raphael-proust
Copy link
Contributor Author

proper shell completion seems like a more general solution to this problem

Shell completion solves only one of the two issues that I mentioned: shell completion. It does nothing for globing.

I had this feature request in the back of my mind for some time, and decided to actually open this issue after I reviewed a change in our CI that introduced the following command: dune build $(for i in src/{,proto_*/}bin_* ; do echo @$i/install ; done) --profile release. Essentially that command has a for-loop in a subshell to work dune's inability to compose with globing.

Additionally, and this is specific to my setup so I don't expect it to weigh much in the balance, I actually already have file completion because of vim's liberal acceptance of what constitute a path. In vim :!dune build @src/li<Tab> will autocomplete just fine on the file name because it ignores the @ (but still passes it along to the command).

Globing is a powerful and pervasive tool I use everyday. I suspect I'm not the only one.

@ejgallego
Copy link
Collaborator

An option that was discussed also was dune build --aliases=... dir1 dir2, in this case dune build dir is just dune build --alias=default dir.

@raphael-proust
Copy link
Contributor Author

That would be a good solution.

@raphael-proust
Copy link
Contributor Author

I'm currently using the following command to work around the inability to glob:

ODOC_WARN_ERROR=true dune build $(for i in src/lib_* ; do echo @$i/doc ; done)

@Alizter Alizter added the feature-request User wanted features label Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request User wanted features
Projects
None yet
Development

No branches or pull requests

3 participants