Open
Description
Problem
When adding a crate with certain features and misspelling one of them, cargo
doesn't suggest features with similar names. This may be confusing if a crate has lots of features. For example:
$ cargo add axum_extra --features typed-headers # The actual feature is `typed-header`, see the last row of disabled features
Updating crates.io index
warning: translating `axum_extra` to `axum-extra`
Adding axum-extra v0.10.1 to dependencies
error: unrecognized feature for crate axum-extra: typed-headers
disabled features:
__private_docs, async-read-body, async-stream, attachment, cookie
cookie-key-expansion, cookie-private, cookie-signed, erased-json
error-response, file-stream, form, json-deserializer, json-lines, multipart
protobuf, query, scheme, typed-header, typed-routing
enabled features:
tracing
Proposed Solution
Instead of just listing all feature flags, cargo
may additionally search for similarly named features and suggest them, so that it looks like the following:
$ cargo add axum_extra --features typed-headers
Updating crates.io index
warning: translating `axum_extra` to `axum-extra`
Adding axum-extra v0.10.1 to dependencies
error: unrecognized feature for crate axum-extra: typed-headers
help: a feature with a similar name exists: `typed-header`
disabled features:
__private_docs, async-read-body, async-stream, attachment, cookie
cookie-key-expansion, cookie-private, cookie-signed, erased-json
error-response, file-stream, form, json-deserializer, json-lines, multipart
protobuf, query, scheme, typed-header, typed-routing
enabled features:
tracing
The help output here is worded the same way the compiler does
Notes
No response