diff --git a/config.example.toml b/config.example.toml index 962a5cd0..632385e2 100644 --- a/config.example.toml +++ b/config.example.toml @@ -34,6 +34,9 @@ # Arguments to pass yay when updating packages #yay_arguments = "--nodevel" +# Manually select Windows updates +# accept_all_windows_updates = false + # Do not set the terminal title #set_title = false # Commands to run before anything diff --git a/src/config.rs b/src/config.rs index cc8abec5..44d49c8c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -69,6 +69,7 @@ pub struct ConfigFile { no_retry: Option, run_in_tmux: Option, cleanup: Option, + accept_all_windows_updates: Option, only: Option>, } @@ -346,6 +347,12 @@ impl Config { self.config_file.assume_yes.unwrap_or(self.opt.yes) } + /// Whether to accept all Windows updates + #[allow(dead_code)] + pub fn accept_all_windows_updates(&self) -> bool { + self.config_file.accept_all_windows_updates.unwrap_or(true) + } + /// Extra yay arguments #[cfg(target_os = "linux")] pub fn yay_arguments(&self) -> &str { diff --git a/src/main.rs b/src/main.rs index d78c573d..6825cfab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -623,7 +623,10 @@ fn run() -> Result<()> { execute( &mut report, "Windows update", - || powershell::Powershell::windows_powershell().windows_update(run_type), + || { + powershell::Powershell::windows_powershell() + .windows_update(run_type, config.accept_all_windows_updates()) + }, config.no_retry(), )?; } diff --git a/src/steps/powershell.rs b/src/steps/powershell.rs index 13d6e1cb..bfea48b4 100644 --- a/src/steps/powershell.rs +++ b/src/steps/powershell.rs @@ -65,7 +65,7 @@ impl Powershell { } #[cfg(windows)] - pub fn windows_update(&self, run_type: RunType) -> Result<()> { + pub fn windows_update(&self, run_type: RunType, accept_all_updates: bool) -> Result<()> { let powershell = require_option(self.path.as_ref())?; if !Self::has_module(&powershell, "PSWindowsUpdate") { @@ -77,7 +77,10 @@ impl Powershell { .execute(&powershell) .args(&[ "-Command", - "Import-Module PSWindowsUpdate; Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -Verbose", + &format!( + "Import-Module PSWindowsUpdate; Install-WindowsUpdate -MicrosoftUpdate {} -Verbose", + if accept_all_updates { "-AcceptAll" } else { "" } + ), ]) .check_run() }