Skip to content

[feature] cargo rm remove deps with a dash instead of an underscore #690

@mrnossiom

Description

@mrnossiom

Hi there,

Context :

We take the lazy_static crate for the sake of the example.
When you use cargo add command to add the dependency but specify it with a dash instead of an underscore, you end up with this message WARN: Added 'lazy_static' instead of 'lazy-static'.

cargo-edit/src/fetch.rs

Lines 74 to 78 in bd49ee2

let dep = read_latest_version(&crate_versions, flag_allow_prerelease)?;
if dep.name != crate_name {
eprintln!("WARN: Added `{}` instead of `{}`", dep.name, crate_name);
}

This happens because the registry does correct this.

Feature :

Now, when we want to remove a dependency but specify the wrong separator (dash or underscore), it errors out and exit.
Would it be possible to remove a dependency using another separator in cargo rm ? Or would it cost too much to implement ?

I didn't have the time to look deeper in the code, but I can try a PR.

Thanks for any further suggestions or approval.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions