cargo-edit
cargo-edit copied to clipboard
RFC: `cargo tidy`
I would like to add a cargo tidy
command. The purpose is to format Cargo.toml. For the kind of things I'd like to implement, see the PingCAP style guide.
I have an initial implementation at https://github.com/nrc/cargo-edit/tree/tidy Currently it only sorts dependencies. I've used this already to produce this PR.
I know there is already cargo add --sort
, but I want to be able to do this without adding a dep, and in the future I would like to extend it to support more formatting and linting.
What do you think? Should I send a PR?
See also: #280
Hey @nrc, I like the idea of the command, but I'm not sure cargo-edit is the right place for it. The reason is it's probably won't reusing much code in cargo-edit and would be specific to PingCAP style guide. Let's see what @killercup thinks.
It does use a fair bit of the Cargo edit code, mostly toml-edit, to be fair, but also the test infra.
I don't think the styling has to be specific to PingCAP, the style guide is meant to be generally useful and I'm happy to discuss the rules here and update the style guide to match.
I think this would be a good addition (and have it format by default maybe?)
I could not find something already implemented, so I decided to write my own Cargo.toml formatter. cargofmt Just now work ordering, and table inlining option. Maybe it will be useful to someone.
Any update here? (actually just to bring up the topic! ;) )
We should probably coordinate with rustfmt on this. Their issue is https://github.com/rust-lang/rustfmt/issues/4091
Closing in favor of rustfmt