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

feature idea: alphabetical order crates and sorted insert #280

Closed
Dowwie opened this issue Apr 9, 2019 · 7 comments
Closed

feature idea: alphabetical order crates and sorted insert #280

Dowwie opened this issue Apr 9, 2019 · 7 comments

Comments

@Dowwie
Copy link

Dowwie commented Apr 9, 2019

What do you think of the idea of a feature to alphabetically order crate dependencies and another to enhance "cargo add " with an ordered insert?

@Dowwie Dowwie closed this as completed Apr 16, 2019
@ordian
Copy link
Collaborator

ordian commented Apr 17, 2019

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.

@Dowwie Dowwie reopened this May 3, 2019
@Dowwie
Copy link
Author

Dowwie commented May 3, 2019

@ordian the comment ownership as you described seems reasonable to me. Would you accept a PR with reordered items as you illustrated?

@ordian
Copy link
Collaborator

ordian commented May 3, 2019

@Dowwie yes please! Feel free to ask any questions in https://gitter.im/cargo-edit/Lobby.

@thiagoarrais
Copy link
Contributor

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?

@Dowwie
Copy link
Author

Dowwie commented Aug 9, 2019

@thiagoarrais how about also sort on insert, such as "cargo add --sorted" ?

@thiagoarrais
Copy link
Contributor

that is done pending merge: #322

@thiagoarrais
Copy link
Contributor

Come to think of it, maybe cargo sort is irrelevant after that...

bors bot added a commit that referenced this issue Aug 13, 2019
322: Include sort flag for adding deps r=ordian a=thiagoarrais

Partial fix for #280

Is this pointing into the right direction?

Co-authored-by: Thiago Arrais <thiago.arrais@gmail.com>
@Dowwie Dowwie closed this as completed Aug 13, 2019
@nrc nrc mentioned this issue Nov 28, 2019
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

3 participants