feat(rustup): add rustup.channels config (#1206)

This commit is contained in:
Gideon
2025-11-06 11:04:00 +01:00
committed by GitHub
parent 549111db3a
commit a52c775247
3 changed files with 27 additions and 1 deletions

View File

@@ -389,6 +389,12 @@ pub struct VscodeConfig {
profile: Option<String>,
}
#[derive(Deserialize, Default, Debug, Merge)]
#[serde(deny_unknown_fields)]
pub struct Rustup {
channels: Option<Vec<String>>,
}
#[derive(Deserialize, Default, Debug, Merge)]
#[serde(deny_unknown_fields)]
/// Configuration file
@@ -473,6 +479,9 @@ pub struct ConfigFile {
#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
vscode: Option<VscodeConfig>,
#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
rustup: Option<Rustup>,
}
fn config_directory() -> PathBuf {
@@ -1493,6 +1502,14 @@ impl Config {
.unwrap_or(true)
}
pub fn rustup_channels(&self) -> Vec<String> {
self.config_file
.rustup
.as_ref()
.and_then(|rustup| rustup.channels.clone())
.unwrap_or_default()
}
pub fn verbose(&self) -> bool {
self.opt.verbose
}

View File

@@ -262,7 +262,11 @@ pub fn run_rustup(ctx: &ExecutionContext) -> Result<()> {
let rustup = require("rustup")?;
print_separator("rustup");
ctx.execute(rustup).arg("update").status_checked()
ctx.execute(rustup)
.arg("update")
.args(ctx.config().rustup_channels())
.status_checked()
}
pub fn run_rye(ctx: &ExecutionContext) -> Result<()> {