mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
fix(complete): Don't complete files for any value
We now need to opt-in to path completions for values, which can be as simple as setting the value parser to be for `PathBuf`s. We'll now show a lot less irrelevant completions.
This commit is contained in:
parent
2e309bd754
commit
244578e9e2
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -563,9 +563,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_complete"
|
||||
version = "4.5.29"
|
||||
version = "4.5.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8937760c3f4c60871870b8c3ee5f9b30771f792a7045c48bcbba999d7d6b3b8e"
|
||||
checksum = "74a01f4f9ee6c066d42a1c8dedf0dcddad16c72a8981a309d6398de3a75b0c39"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"clap_lex",
|
||||
|
@ -36,7 +36,7 @@ cargo-util = { version = "0.2.14", path = "crates/cargo-util" }
|
||||
cargo-util-schemas = { version = "0.7.0", path = "crates/cargo-util-schemas" }
|
||||
cargo_metadata = "0.18.1"
|
||||
clap = "4.5.18"
|
||||
clap_complete = { version = "4.5.29", features = ["unstable-dynamic"] }
|
||||
clap_complete = { version = "4.5.32", features = ["unstable-dynamic"] }
|
||||
color-print = "0.3.6"
|
||||
core-foundation = { version = "0.10.0", features = ["mac_os_10_7_support"] }
|
||||
crates-io = { version = "0.40.4", path = "crates/crates-io" }
|
||||
|
@ -34,8 +34,11 @@ fn main() {
|
||||
let _span = tracing::span!(tracing::Level::TRACE, "completions").entered();
|
||||
let args = std::env::args_os();
|
||||
let current_dir = std::env::current_dir().ok();
|
||||
let completer =
|
||||
clap_complete::CompleteEnv::with_factory(|| cli::cli(&mut gctx)).var("CARGO_COMPLETE");
|
||||
let completer = clap_complete::CompleteEnv::with_factory(|| {
|
||||
let mut gctx = GlobalContext::default().expect("already loaded without errors");
|
||||
cli::cli(&mut gctx)
|
||||
})
|
||||
.var("CARGO_COMPLETE");
|
||||
if completer
|
||||
.try_complete(args, current_dir.as_deref())
|
||||
.unwrap_or_else(|e| {
|
||||
|
Loading…
x
Reference in New Issue
Block a user