Skip to content

Commit bffbb60

Browse files
authored
feat(cli): Add support for completing --config values in Bash (#16245)
### 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> ```
2 parents e2c8f3c + 35c827a commit bffbb60

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/etc/cargo.bashcomp.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ _cargo()
3636
local opt_verbose='-v --verbose'
3737
local opt_quiet='-q --quiet'
3838
local opt_color='--color'
39-
local opt_common="$opt_help $opt_verbose $opt_quiet $opt_color"
39+
local opt_config='--config'
40+
local opt_common="$opt_help $opt_verbose $opt_quiet $opt_color $opt_config"
4041
local opt_pkg_spec='-p --package --all --exclude --workspace'
4142
local opt_pkg='-p --package'
4243
local opt_feat='-F --features --all-features --no-default-features'
@@ -143,6 +144,9 @@ _cargo()
143144
--target-dir|--path)
144145
_filedir -d
145146
;;
147+
--config)
148+
_filedir
149+
;;
146150
help)
147151
_ensure_cargo_commands_cache_filled
148152
COMPREPLY=( $( compgen -W "$__cargo_commands_cache" -- "$cur" ) )

0 commit comments

Comments
 (0)