What do you think of the idea of a feature to alphabetically order crate dependencies and another to enhance "cargo add
Hey @Dowwie! Are you not interested in this feature anymore? The only tricky question is what to do with the comments during reordering. Currently, the underlying toml library assumes that comment above and on the right of a key-value pair "belong" to it. e.g. when reordering this toml
# comment 2
dep2 = "version2" # comment 3
# comment 1
dep1 = "version1"
it would look like
# comment 1
dep1 = "version1"
# comment 2
dep2 = "version2" # comment 3
If this is what you would expect, then it can be fairly easily implemented. I don't have time to implement it, but would be happy to mentor.
@ordian the comment ownership as you described seems reasonable to me. Would you accept a PR with reordered items as you illustrated?
@Dowwie yes please! Feel free to ask any questions in https://gitter.im/cargo-edit/Lobby.
What would a good format for the feature be? I'm thinking
$ cargo sort --help
cargo-sort 0.3.3
Sort dependencies in a Cargo.toml manifest file.
USAGE:
cargo sort [FLAGS] [OPTIONS]
FLAGS:
-h, --help Prints help information
--dry-run Print changes to be made without making them.
-V, --version Prints version information
OPTIONS:
--manifest-path <path> Path to the manifest to upgrade
This command sorts all dependencies in a Cargo.toml manifest file alphabetically.
What do you think?
@thiagoarrais how about also sort on insert, such as "cargo add
that is done pending merge: #322
Come to think of it, maybe cargo sort is irrelevant after that...