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

RFC: cargo tidy #361

Closed
nrc opened this issue Nov 28, 2019 · 10 comments
Closed

RFC: cargo tidy #361

nrc opened this issue Nov 28, 2019 · 10 comments

Comments

@nrc
Copy link

nrc commented Nov 28, 2019

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

@ordian
Copy link
Collaborator

ordian commented Nov 29, 2019

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.

@nrc
Copy link
Author

nrc commented Nov 29, 2019

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.

@jamesmcm
Copy link

jamesmcm commented Jan 15, 2020

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

@kgv
Copy link

kgv commented Apr 8, 2020

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.

@omid
Copy link

omid commented Sep 24, 2020

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

@epage
Copy link
Collaborator

epage commented Jul 14, 2022

We should probably coordinate with rustfmt on this. Their issue is rust-lang/rustfmt#4091

@epage
Copy link
Collaborator

epage commented Sep 27, 2022

Closing in favor of rustfmt

@epage epage closed this as completed Sep 27, 2022
@sjackman
Copy link

sjackman commented Dec 13, 2023

The rustfmt PR has been open since 2022-02-25

Would you be open to accepting a PR that provides cargo tidy to sort dependencies?

@epage
Copy link
Collaborator

epage commented Dec 13, 2023

No. At this point, cargo-edit is focused mostly on work that can be upstreamed and that would be a dead end. I would encourage you to help contribute to the rustfmt effort instead.

@sjackman
Copy link

I found cargo-sort to sort dependencies in Cargo.toml files, and it works well! https://crates.io/crates/cargo-sort

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

No branches or pull requests

7 participants