diff --git a/src/config.rs b/src/config.rs index 2fcd619a..d79b0ce3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -160,6 +160,7 @@ pub struct Windows { accept_all_updates: Option, self_rename: Option, open_remotes_in_new_terminal: Option, + enable_winget: Option, } #[derive(Deserialize, Default, Debug)] @@ -859,4 +860,13 @@ impl Config { true } + + pub fn enable_winget(&self) -> bool { + return self + .config_file + .windows + .as_ref() + .and_then(|w| w.enable_winget) + .unwrap_or(false); + } } diff --git a/src/steps/os/windows.rs b/src/steps/os/windows.rs index 254754d5..290465e1 100644 --- a/src/steps/os/windows.rs +++ b/src/steps/os/windows.rs @@ -7,7 +7,7 @@ use log::debug; use crate::execution_context::ExecutionContext; use crate::executor::{CommandExt, RunType}; -use crate::terminal::print_separator; +use crate::terminal::{print_separator, print_warning}; use crate::utils::require; use crate::{error::SkipStep, steps::git::Repositories}; use crate::{powershell, Step}; @@ -42,6 +42,11 @@ pub fn run_winget(ctx: &ExecutionContext) -> Result<()> { print_separator("winget"); + if !ctx.config().enable_winget() { + print_warning("Winget is disabled by default. Enable it by setting enable_winget=true in the [windows] section in the configuration."); + return Err(SkipStep(String::from("Winget is disabled by default")).into()); + } + ctx.run_type().execute(&winget).args(&["upgrade", "--all"]).check_run() }