Skip to content

Conversation

nooma-42
Copy link
Contributor

What does this PR try to resolve?

Related to #14520

This PR introduces auto-completion for the cargo add --path option. When a user types cargo add --path and 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 --path
Press 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

@rustbot
Copy link
Collaborator

rustbot commented Mar 10, 2025

r? @weihanglo

rustbot has assigned @weihanglo.
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. Command-add S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 10, 2025
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look nice! Thanks!

I wonder if we want to de-prioritize hidden directories, but that can leave for future discussion.

@weihanglo weihanglo enabled auto-merge March 10, 2025 04:03
@weihanglo weihanglo added this pull request to the merge queue Mar 10, 2025
Merged via the queue into rust-lang:master with commit 42b6ae8 Mar 10, 2025
21 checks passed
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()),
)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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
@rustbot rustbot added this to the 1.87.0 milestone 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. Command-add 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