Provide multiple files to various CLI subcommands#2169
Conversation
Gabriella439
left a comment
There was a problem hiding this comment.
Looks great! Just a few comments
Co-authored-by: Gabriel Gonzalez <Gabriel439@gmail.com>
|
Thanks for the review @Gabriel439 😄 |
TristanCacqueray
left a comment
There was a problem hiding this comment.
The change seems to work as expected, thanks! Would it be ok to keep a deprecated --inplace argument to ease the transition to avoid breaking CI?
I am already breaking backwards compatibility with
In this PR? I thought everything passed at the moment, or are there other tests that are only run on I still need to have a closer look at documentation to make sure the CLI flags are up to date there as well. I should also add a changelog entry for this change. 😄 |
|
I agree it's better to make breaking API changes in one go. Though this one is likely to affect integration jobs, e.g. https://github.com/search?q=%22dhall+format+--inplace%22&type=Code . |
|
One thing that can smooth the transition is to make |
|
If the switch does nothing, then it might be better to make it fail though. Note that this will also break the vim plugin according to https://github.com/vmchale/dhall-vim/blob/master/ftplugin/dhall.vim#L32 |
|
I have added We can revert commit 2d6035a at a later time if when we want to remove the flag entirely. |
|
It looks like But at least with this deprecation approach we shouldn't break too many workflows/scripts. Do you think something similar is needed for |
Gabriella439
left a comment
There was a problem hiding this comment.
Sorry, I missed that you moved this out of Draft status. This looks great!
|
No worries, I don't work on this as often as I'd like, so slow PR progress works for me. As long as it's not blocking others. But I think it's ready now, so I will merge it, and hopefully not too many people will have issues with the new CLI API 😁 |
This PR makes it possible to provide multiple files as argument to the
format,freeze, andlintsubcommands.These subcommands already had to deal with potentially multiple files via the use of the
transitiveflag.Motivation
It is common in unix tools for the CLI to accept multiple file arguments as input, so it would be great if
dhallcould do the same where possible/it makes sense.A more concrete motivation is that I would like
dhall formatto be easily usable with formatting tools/managers such as https://github.com/numtide/treefmt.treefmthas a specification of sorts for what basic API formatters should expose as part of their CLI: https://numtide.github.io/treefmt/docs/formatters-spec.html. This specification requires the ability for a formatter to take multiple file arguments.Providing multiple files as argument as opposed to calling these subcommands in a loop in
bash(or withxargs -n1) has some performance benefits since we don't have to start a new process for every file.Changes
This PR make
inplaceimplicit for file arguments (so that flag is removed). That was already kind of the case for these 3 subcommands as the only way to provide a file argument wasinplaceortransitivewhich impliedinplace.This PR changed the
transitiveflag from a flag that takes a file path to a switch that applies to all the input files.Stdin is still supported, in 2 ways now: no file arguments, or a file argument
"-". This should enable applying the subcommands to both stdin and input files at the same time.Note: stdin is still a non-transitive input even when the
transitiveswitch is on.Other subcommands might benefit from taking multiple files as input as well, I simply started with the ones I thought needed it the most.