cargo-edit icon indicating copy to clipboard operation
cargo-edit copied to clipboard

RFC: `cargo tidy`

Open nrc opened this issue 5 years ago • 6 comments

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

nrc avatar Nov 28 '19 02:11 nrc

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.

ordian avatar Nov 29 '19 18:11 ordian

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.

nrc avatar Nov 29 '19 23:11 nrc

I think this would be a good addition (and have it format by default maybe?)

jamesmcm avatar Jan 15 '20 09:01 jamesmcm

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.

kgv avatar Apr 08 '20 23:04 kgv

Any update here? (actually just to bring up the topic! ;) )

omid avatar Sep 24 '20 08:09 omid

We should probably coordinate with rustfmt on this. Their issue is https://github.com/rust-lang/rustfmt/issues/4091

epage avatar Jul 14 '22 12:07 epage

Closing in favor of rustfmt

epage avatar Sep 27 '22 17:09 epage