diff --git a/config.example.toml b/config.example.toml index af4d60a3..276f9e57 100644 --- a/config.example.toml +++ b/config.example.toml @@ -103,8 +103,8 @@ # enable_pipupgrade = true ###disabled by default # pipupgrade_arguments = "-y -u --pip-path pip" ###disabled by default -# For the poetry step, by default, Topgrade skips its update if poetry is not -# installed with the official script. This configuration entry forces Topgrade +# For the poetry step, by default, Topgrade skips its update if poetry is not +# installed with the official script. This configuration entry forces Topgrade # to run the update in this case. # # (default: false) @@ -315,3 +315,9 @@ # If enabled, each updated version above will be marked with `zigup keep`. # (default: false) # cleanup = false + +[vscode] +# If this is set and is a non-empty string, it specifies the profile the +# extensions should be updated for. +# (default: this won't be set by default) +# profile = "" diff --git a/src/config.rs b/src/config.rs index c722f881..dcbd7f14 100644 --- a/src/config.rs +++ b/src/config.rs @@ -471,6 +471,12 @@ pub struct Zigup { cleanup: Option, } +#[derive(Deserialize, Default, Debug, Merge)] +#[serde(deny_unknown_fields)] +pub struct VscodeConfig { + profile: Option, +} + #[derive(Deserialize, Default, Debug, Merge)] #[serde(deny_unknown_fields)] /// Configuration file @@ -543,6 +549,9 @@ pub struct ConfigFile { #[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)] zigup: Option, + + #[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)] + vscode: Option, } fn config_directory() -> PathBuf { @@ -1710,6 +1719,17 @@ impl Config { .and_then(|zigup| zigup.cleanup) .unwrap_or(false) } + + pub fn vscode_profile(&self) -> Option<&str> { + let vscode_cfg = self.config_file.vscode.as_ref()?; + let profile = vscode_cfg.profile.as_ref()?; + + if profile.is_empty() { + None + } else { + Some(profile.as_str()) + } + } } #[cfg(test)] diff --git a/src/steps/generic.rs b/src/steps/generic.rs index 086ae277..46a4cbfd 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -469,10 +469,19 @@ pub fn run_vscode_extensions_update(ctx: &ExecutionContext) -> Result<()> { print_separator("Visual Studio Code extensions"); - ctx.run_type() - .execute(vscode) - .arg("--update-extensions") - .status_checked() + if let Some(profile) = ctx.config().vscode_profile() { + ctx.run_type() + .execute(vscode) + .arg("--profile") + .arg(profile) + .arg("--update-extensions") + .status_checked() + } else { + ctx.run_type() + .execute(vscode) + .arg("--update-extensions") + .status_checked() + } } pub fn run_pipx_update(ctx: &ExecutionContext) -> Result<()> {