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 request: have --features flag check available features #474

Closed
savente93 opened this issue Jul 11, 2021 · 4 comments · Fixed by #545
Closed

feature request: have --features flag check available features #474

savente93 opened this issue Jul 11, 2021 · 4 comments · Fixed by #545

Comments

@savente93
Copy link
Contributor

cargo add by default already queries crates.io for the latest versions which is great. I'm wondering if it's also possible to have it query available feature flags at the same time? This comes from a slight frustration in the following scenario:

> cargo add -p common csv --features serde
    Updating 'https://github.com/rust-lang/crates.io-index' index
      Adding csv v1.1.6 to dependencies with features: ["serde"]
> cargo build
    the package `common` depends on `csv`, with features: `serde` but `csv` does not have these features.
    It has a required dependency with that name, but only optional dependencies can be used as features.

This is a frequent occurrence since a lot of crates have common features like serde or derive but they're often used interchangeably so it can be frustrating to try and find out which one it is. I personally use cargo add all the time with this, and it would be a really nice quality of life feature to have cargo add check for this. Would this be possible? In any case, thanks for all the great work!

@epage
Copy link
Collaborator

epage commented Sep 21, 2021

The registry contains features, we also have logic for getting Cargo.toml from git repos and paths. The main issue is plugging all of this together to get the list of features to validate them.

@epage
Copy link
Collaborator

epage commented Sep 21, 2021

#193 is related

@savente93
Copy link
Contributor Author

The main grievance I had when opening this issue is mostly addressed now that #538 et. al. is merged, so I just wanted to check if anyone thinks this would be a substantial enough improvement to add? I guess it would guard against typos etc. I'm happy to work on it sometime if people still think it would be worth it, otherwise I'm happy to close it.

@epage
Copy link
Collaborator

epage commented Nov 18, 2021

Oh, I think validating inputs would be a big help! I see showing the list as something to help with discoverability. For myself, if I thought I knew what the features were already, I'm unlikely to check the list. This is on top of identifying typos, as you mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants