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

Allow a wildcard *.rs that can be used to format all .rs file in that directory and it's subdirectories #2426

Closed
ishanjain28 opened this issue Feb 11, 2018 · 4 comments

Comments

@ishanjain28
Copy link

Sometimes, I want to run rustfmt on all source files in a directory. There is a * wildcard that can be used but it also tries to format toml and any other files in the directory.

I think, There should be a *.rs wildcard that formats all Rust source files in the specified directory and also any rust files in the subdirectories of specified directory.

@ishanjain28
Copy link
Author

On a second thought, Formatting all .rs files in a directory and it's subdirectories might cause performance issues and there might be someone who doesn't wants to format all the source files in subdirectories.

So, A -r --recursive flag is probably a good idea.

@ishanjain28
Copy link
Author

Oh, Just found out about the --skip-children option. It automatically formats all imported modules in the file. My issue is now resolved but -r --recursive and *.rs wildcard might be useful for someone who has different/unrelated .rs files in a directory.

@nrc
Copy link
Member

nrc commented Feb 11, 2018

Rustfmt formats programs rather than files. If you format lib.rs/main.rs, it will format all files in the library/application.

@nrc nrc closed this as completed Feb 11, 2018
laanwj added a commit to laanwj/cln4rust that referenced this issue Sep 6, 2018
Tracking these through issues is better.

Also, `rustfmt` only needs to be called on top-level files
(see rust-lang/rustfmt#2426). It does
need to be called on every example, though, as those count as top-level
files.

Mention that signed GPG commits are preferred.

Tree-SHA512: 5e4a308e71a6dd437a93f337820eb817185c235bb2796bcf28d91e1e45f91cbce5dc7e305e7adc7ee96c4292ab91fa89eb932a0b0007f98191740a9d15ddb03f
@AlexAegis
Copy link

AlexAegis commented Dec 8, 2019

And how about workspaces?
Would be nice to just pass a glob like so:
rustfmt src/**/*.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants