killercup / killercup/cargo-edit

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

Open
#690 4 comments 0 reactions 0 assignees View on GitHub
cargo-rm
Dominant language
Rust
Stars
3.5k
Forks
166
PR merge metrics
No merged PRs in 30d

Description

## 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'`.
https://github.com/killercup/cargo-edit/blob/bd49ee227183fceb0b3cd488f0f239bfa58118bd/src/fetch.rs#L74-L78
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.

Contributor guide

Open the contributing guide

Research direction

Start with the cargo rm dependency lookup and removal path, then compare its name handling with fetch.rs lines 74-78, which are linked in the issue. Verify the behavior using the lazy_static/lazy-static example: specifying either separator should remove the dependency without an error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.