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

Consider aliasing cargo new --library to cargo new --lib rather than throwing an error for it #12467

Closed
kayagokalp opened this issue Aug 9, 2023 · 3 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@kayagokalp
Copy link

Problem

Currently if a cargo user wants to create a library project, they need to use cargo new --lib and cargo new --library throws an error with a nice error message:

error: unexpected argument '--library' found

  tip: a similar argument exists: '--lib'

Usage: cargo new --lib <path>

For more information, try '--help'.

But --library and --lib means the same thing and I feel like there would not be an ambiguity if we also accept --library.

I would argue that it would feel more natural to some people.

Proposed Solution

If there are no strong reasons to not do that, I think we can also accept --library as a valid argument and basically make sure that cargo new --library and cargo new --lib actually does the same thing.

This can be further expanded --bin and --binary.

Notes

No response

@kayagokalp kayagokalp added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Aug 9, 2023
@weihanglo
Copy link
Member

Thanks for the idea.

I feel like the error message is quite clear to route you to the right argument. Also, bin and lib are already used everywhere in other subcommands, Cargo.toml, as well as rustc.

I lean towards not adding clever aliases at this moment, in order to reduce the overhead for both users and developers.

@epage
Copy link
Contributor

epage commented Aug 9, 2023

Agreed. When I first read this, I thought it was for the other way around, which made sense to me. For better or worse, the rust ecosystem uses a lot of abbreviations.

If the existing clap message wasn't useful, we would have instead wanted to make it more useful at a later point, like when clap-rs/clap#4706 is implemented. Since it is useful, I don't see something to do here.

@arlosi
Copy link
Contributor

arlosi commented Aug 9, 2023

Agreed. Since the error message suggests the correct flag, I think we can close this.

Thank you for the suggestion.

@arlosi arlosi closed this as not planned Won't fix, can't repro, duplicate, stale Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

4 participants