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

feat(completer): Added completion for --features flag #15309

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Gmin2
Copy link
Contributor

@Gmin2 Gmin2 commented Mar 13, 2025

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

Screenshot from 2025-03-14 03-36-53

Related to #14520

How should we test and review this PR?

by running cargo build --features <TAB>, cargo run --features <TAB>

@rustbot
Copy link
Collaborator

rustbot commented Mar 13, 2025

r? @ehuss

rustbot has assigned @ehuss.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-cli Area: Command-line interface, option parsing, etc. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 13, 2025
@Gmin2
Copy link
Contributor Author

Gmin2 commented Mar 13, 2025

@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

Comment on lines +1127 to +1133
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();
Copy link
Contributor

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

Comment on lines +1142 to +1146
for dep in package.dependencies() {
if dep.is_optional() {
features.insert(dep.name_in_toml().to_string());
}
}
Copy link
Contributor

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?

Comment on lines +1183 to +1186
Ok(features
.into_iter()
.map(|name| clap_complete::CompletionCandidate::new(name))
.collect())
Copy link
Contributor

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?

@ehuss ehuss assigned epage and unassigned ehuss Mar 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Area: Command-line interface, option parsing, etc. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants