-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat(completer): Added completion for --features
flag
#15309
base: master
Are you sure you want to change the base?
Conversation
@epage suggestion will be appreciated on how can i improve this like should i include some description ? or something like that, as i have not discussed with yu earlier and pick directly from the parent issue |
let current_dir = std::env::current_dir()?; | ||
|
||
let current_pkg = ws | ||
.members() | ||
.find(|pkg| current_dir.starts_with(pkg.root())) | ||
.or_else(|| ws.members().next()) | ||
.cloned(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For --bin [TAB]
, we complete for any package in the workspace in case --package
is used
for dep in package.dependencies() { | ||
if dep.is_optional() { | ||
features.insert(dep.name_in_toml().to_string()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these in the package's summary?
Ok(features | ||
.into_iter() | ||
.map(|name| clap_complete::CompletionCandidate::new(name)) | ||
.collect()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we sort or de-duplicate?
What does this PR try to resolve?
This attempts to complete the autocompleter for
cargo build --features <TAB>
,cargo run --features <TAB>
It loads all the features that are there in the profile section of Cargo.toml
Related to #14520
How should we test and review this PR?
by running
cargo build --features <TAB>
,cargo run --features <TAB>