feat: add completions for add --path#15288
Merged
weihanglo merged 1 commit intorust-lang:masterfrom Mar 10, 2025
Merged
Conversation
Collaborator
|
r? @weihanglo rustbot has assigned @weihanglo. Use |
weihanglo
approved these changes
Mar 10, 2025
Member
weihanglo
left a comment
There was a problem hiding this comment.
Look nice! Thanks!
I wonder if we want to de-prioritize hidden directories, but that can leave for future discussion.
epage
reviewed
Mar 10, 2025
Comment on lines
+103
to
+107
| .conflicts_with("git") | ||
| .add(clap_complete::engine::ArgValueCompleter::new( | ||
| clap_complete::engine::PathCompleter::any() | ||
| .filter(|path| path.join("Cargo.toml").exists()), | ||
| )), |
Contributor
There was a problem hiding this comment.
For future changes, should we refactor out these --path completers into https://github.com/rust-lang/cargo/blob/master/src/cargo/util/command_prelude.rs ? We have two already and I believe there is a third and we'll be wanting to add more context to these
This was referenced Mar 10, 2025
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 14, 2025
Update cargo 15 commits in ab1463d632528e39daf35f263e10c14cbe590ce8..6cf8267012570f63d6b86e85a2ae5627de52df9e 2025-03-08 01:45:05 +0000 to 2025-03-14 15:25:36 +0000 - feat(package): add --exclude-lockfile flag (rust-lang/cargo#15234) - Redox OS is part of the unix family (rust-lang/cargo#15307) - docs(ref): Mention `x.y.*` as a kind of version requirement to avoid. (rust-lang/cargo#15310) - fix(run): Disambiguate bins from different packages that share a name (rust-lang/cargo#15298) - cargo vendor: Add context which workspace failed to resolve (rust-lang/cargo#15297) - docs(ref): Note that target-edition is deprecated (rust-lang/cargo#15292) - refactor(toml): Centralize target descriptions (rust-lang/cargo#15291) - docs(refs): Add `unsafe` to `extern` while using build scripts in Cargo Book (rust-lang/cargo#15294) - Replace unmaintained humantime crate with jiff (rust-lang/cargo#15290) - Add terminal integration via ANSI OSC 9;4 sequences (rust-lang/cargo#14615) - feat: add completions for add --path (rust-lang/cargo#15288) - Allow `term.progress.when` to default (rust-lang/cargo#15287) - docs: spelling and grammar fixes (rust-lang/cargo#15284) - chore(deps): update cargo-semver-checks to v0.40.0 (rust-lang/cargo#15282) - Typo fixes (rust-lang/cargo#15280) r? ghost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR try to resolve?
Related to #14520
This PR introduces auto-completion for the
cargo add --pathoption. When a user typescargo add --pathand presses the TAB key, the system will automatically detect directories in the current path and suggestion prioritizes directory containing a Cargo.toml file.How should we test and review this PR?
To verify this feature, follow these steps:
In the terminal, type
cargo add --pathPress the TAB key.
You should see suggestions only for directories in the current path that contain a Cargo.toml file being prioritized, such as ./src/ (if ./src/Cargo.toml exists).
2025-03-10.11.52.37.mov