Skip to content

Conversation

@nspin
Copy link
Contributor

@nspin nspin commented Nov 12, 2025

What does this PR try to resolve?

Currently, cargo.bashcomp.sh doesn't support completing the --config flag, let alone its value. This PR adds support for completing both the --config flag and a _filedir value for it. This support includes both cases where it appears before the cargo subcommand, and cases where it appears after. In the process of implementing the former, I also added support for completing values for --color before the cargo subcommand. Currently, completing values for --color is only supported after the cargo subcommand.

How to test and review this PR?

In a Bash shell, run:

source src/etc/cargo.bashcomp.sh

Then, observe that the following completions behave as expected:

cargo --co<tab>
cargo --config <tab>
cargo --color <tab>
cargo build --co<tab>
cargo build --config <tab>

Adds support for completing --config values with _filedir, but only when
they appear after the cargo subcommand.
@rustbot rustbot added A-completions Area: shell completions S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 12, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 12, 2025

r? @epage

rustbot has assigned @epage.
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

@epage
Copy link
Contributor

epage commented Nov 12, 2025

The first commit, I would be fine merging immediately. The second commit, I don't quite feel qualified to review. If you want to split this PR, then we can get that first commit merged.

Note: overall our focused has shifted towards stabilizing https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#native-completions

@nspin nspin force-pushed the pr/bash-completion-config branch from 87566e1 to 35c827a Compare November 13, 2025 00:28
@nspin
Copy link
Contributor Author

nspin commented Nov 13, 2025

The first commit, I would be fine merging immediately. The second commit, I don't quite feel qualified to review. If you want to split this PR, then we can get that first commit merged.

I've removed the second commit from this PR, leaving only the first.

The second commit depends on the first, so I'll open that PR after this is merged.

Note: overall our focused has shifted towards stabilizing https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#native-completions

Thanks for the heads up, I'll look into adding this feature over there too.

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.

@nspin
Copy link
Contributor Author

nspin commented Nov 13, 2025

I've opened #16249, which adds this feature for native-completions.

@weihanglo weihanglo added this pull request to the merge queue Nov 13, 2025
Merged via the queue into rust-lang:master with commit bffbb60 Nov 13, 2025
39 of 52 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-completions Area: shell completions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants