Skip to content

A setting and/or flag to add short version numbers with cargo add #12072

@docwilco

Description

@docwilco

Problem

Currently, cargo add will add full latest version number to Cargo.toml. Especially in new projects (where a lot of add actions happen,) this might not be ideal. I at least, find myself removing patch and ofteneven minor version numbers, so that I can occasionally just remove Cargo.lock and get everything upgraded.

Proposed Solution

[add]
version-specificity="major"

resulting in cargo add tokio adding

[dependencies]
tokio = "1"

and

[add]
version-specificity="minor"

resulting in cargo add tokio adding

[dependencies]
tokio = "1.28"

Possible settings major|minor|patch with patch being the default.

Not quite sure about commandline flags, am absolutely open to suggestions there.

Notes

I am absolutely open to writing a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions