feat(vscode): updated extensions for a given profile (#1022)
* [feat] select user profile for vscode * [feat] Update example config file * [fix] Remove unneeded imports * [feat] PR comments * [fix] formatting
This commit is contained in:
committed by
GitHub
parent
3e0c21e981
commit
66a12cc8bf
@@ -471,6 +471,12 @@ pub struct Zigup {
|
||||
cleanup: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default, Debug, Merge)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct VscodeConfig {
|
||||
profile: Option<String>,
|
||||
}
|
||||
|
||||
#[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<Zigup>,
|
||||
|
||||
#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
|
||||
vscode: Option<VscodeConfig>,
|
||||
}
|
||||
|
||||
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)]
|
||||
|
||||
@@ -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<()> {
|
||||
|
||||
Reference in New Issue
Block a user