brioche-dev / brioche

A delicious package manager
https://brioche.dev
MIT License
291 stars 4 forks source link

[CLI] Format a file/folder instead of a project #76

Open jaudiger opened 1 week ago

jaudiger commented 1 week ago

Usually, formatters take as input a list of files, or folders, or even a glob pattern. It enables granularity and lets the end user choose between formatting a whole folder recursively or just a single file.

The brioche formatter takes another approach, which is to format per project (and without giving any granularity):

Format the Brioche files in a project

Usage: brioche fmt [OPTIONS] --project <PROJECT>

Would it make sense to switch to a file/folder formatter, or should we continue to format per project? The discussion starts here (#75) could also be extended to this issue if the option 2 is chosen.

kylewlacy commented 1 week ago

I personally like being able to enforce per-project formatting, and there's precedence with cargo fmt at least. But I'm not against supporting both, and I think it should be fairly straightforward to support both by taking a list of positional arguments and --project arguments then figuring out which files and/or projects to format from that. I might suggest disallowing formatting both projects and individual files in a single invocation (since it seems kind of ambiguous to me what should happen in that case) as a starting point, but I'd be open to a contribution for this feature