Skip to content

feat(cli): complete --config and --color before command#16780

Merged
weihanglo merged 1 commit intorust-lang:masterfrom
nspin:pr/bash-complete-config-color-before-cmd
Mar 22, 2026
Merged

feat(cli): complete --config and --color before command#16780
weihanglo merged 1 commit intorust-lang:masterfrom
nspin:pr/bash-complete-config-color-before-cmd

Conversation

@nspin
Copy link
Contributor

@nspin nspin commented Mar 22, 2026

What does this PR try to resolve?

Split from #16245 (see #16245 (comment)).

Currently, cargo.bashcomp.sh supports completing values for --color and --config only in cases where they appear after the subcommand. This PR add support for completing values for these two flags when they appear before the subcommand.

How to test and review this PR?

In a Bash shell, run:

source src/etc/cargo.bashcomp.sh

Before this patch, the following behaves as expected (suggests colors or paths):

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

but the following does not behave as expected (colors or paths are not suggested):

cargo --config <tab>
cargo --color <tab>

With this patch applied, all of the following behave as expected:

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

Signed-off-by: Nick Spinale <nick@nickspinale.com>
@rustbot rustbot added A-completions Area: shell completions S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 22, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 22, 2026

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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

@nspin nspin changed the title feat(cli): complete --config and --color before command feat(cli): complete --config and --color before command Mar 22, 2026
Copy link
Member

Choose a reason for hiding this comment

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

This is nice. I feel like there are more global options that we might want to have such kind of completions. Not a blocker though.

@weihanglo weihanglo added this pull request to the merge queue Mar 22, 2026
Merged via the queue into rust-lang:master with commit 1576a6c Mar 22, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 22, 2026
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