From d838eb588bc21352335beb27b398f3e7624a5299 Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko Date: Tue, 30 Jun 2020 11:55:39 +0300 Subject: [PATCH] Add support for -y flag in Chocolatey (#457) --- src/main.rs | 2 +- src/steps/os/windows.rs | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index f92c13a0..2973771b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -139,7 +139,7 @@ fn run() -> Result<()> { #[cfg(windows)] { if config.should_run(Step::Chocolatey) { - runner.execute("Chocolatey", || windows::run_chocolatey(run_type))?; + runner.execute("Chocolatey", || windows::run_chocolatey(&ctx))?; } if config.should_run(Step::Scoop) { diff --git a/src/steps/os/windows.rs b/src/steps/os/windows.rs index 265bf273..68370489 100644 --- a/src/steps/os/windows.rs +++ b/src/steps/os/windows.rs @@ -7,11 +7,21 @@ use crate::utils::require; use anyhow::Result; use std::process::Command; -pub fn run_chocolatey(run_type: RunType) -> Result<()> { +pub fn run_chocolatey(ctx: &ExecutionContext) -> Result<()> { let choco = require("choco")?; + let yes = ctx.config().yes(); print_separator("Chocolatey"); - run_type.execute(&choco).args(&["upgrade", "all"]).check_run() + + let mut command = ctx.run_type().execute(&choco); + + command.args(&["upgrade", "all"]); + + if yes { + command.arg("--yes"); + } + + command.check_run() } pub fn run_scoop(cleanup: bool, run_type: RunType) -> Result<()> {