Skip to content

Commit 22f4bc4

Browse files
committed
use subcommand candidate
1 parent dbb5254 commit 22f4bc4

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/bin/cargo/cli.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -691,26 +691,20 @@ See '<cyan,bold>cargo help</> <cyan><<command>></>' for more information on a sp
691691
}))
692692
}).collect()
693693
})))
694-
.arg( Arg::new("toolchain")
695-
.help("Specifies the toolchain to use for this command")
696-
.value_name("TOOLCHAIN")
697-
.action(ArgAction::Set)
698-
.add(clap_complete::engine::ArgValueCompleter::new(|partial: &OsStr| {
699-
let toolchains = get_toolchains_from_rustup();
700-
701-
toolchains
694+
.add(clap_complete::engine::SubcommandCandidates::new(|| {
695+
get_toolchains_from_rustup()
702696
.into_iter()
703-
.filter(|t| OsStr::new(t).as_encoded_bytes().starts_with(partial.as_encoded_bytes()))
704697
.map(|t| clap_complete::CompletionCandidate::new(t))
705698
.collect()
706-
})))
699+
}))
707700
.subcommands(commands::builtin())
708701
}
709702

710703
fn get_toolchains_from_rustup() -> Vec<String> {
711704
let output = std::process::Command::new("rustup")
712705
.arg("toolchain")
713706
.arg("list")
707+
.arg("-q")
714708
.output()
715709
.unwrap();
716710

0 commit comments

Comments
 (0)