diff --git a/src/main.rs b/src/main.rs index bdc01c54..92b5f197 100644 --- a/src/main.rs +++ b/src/main.rs @@ -292,7 +292,7 @@ fn run() -> Result<()> { runner.execute(Step::Choosenim, "choosenim", || generic::run_choosenim(&ctx))?; runner.execute(Step::Cargo, "cargo", || generic::run_cargo_update(&ctx))?; runner.execute(Step::Flutter, "Flutter", || generic::run_flutter_upgrade(run_type))?; - runner.execute(Step::Emacs, "Emacs", || emacs.upgrade(run_type))?; + runner.execute(Step::Emacs, "Emacs", || emacs.upgrade(&ctx))?; runner.execute(Step::Opam, "opam", || generic::run_opam_update(run_type))?; runner.execute(Step::Vcpkg, "vcpkg", || generic::run_vcpkg_update(run_type))?; runner.execute(Step::Pipx, "pipx", || generic::run_pipx_update(run_type))?; diff --git a/src/steps/emacs.rs b/src/steps/emacs.rs index 1c34d45f..9d9a6fd6 100644 --- a/src/steps/emacs.rs +++ b/src/steps/emacs.rs @@ -1,4 +1,4 @@ -use crate::executor::RunType; +use crate::execution_context::ExecutionContext; use crate::terminal::print_separator; use crate::utils::{require, require_option, PathExt}; use anyhow::Result; @@ -60,25 +60,32 @@ impl Emacs { self.directory.as_ref() } - fn update_doom(doom: &Path, run_type: RunType) -> Result<()> { + fn update_doom(doom: &Path, ctx: &ExecutionContext) -> Result<()> { print_separator("Doom Emacs"); - run_type.execute(doom).args(&["-y", "upgrade"]).check_run() + let mut command = ctx.run_type().execute(doom); + command.args(&["-y", "upgrade"]); + + if ctx.config().yes() { + command.arg("--force"); + } + + command.check_run() } - pub fn upgrade(&self, run_type: RunType) -> Result<()> { + pub fn upgrade(&self, ctx: &ExecutionContext) -> Result<()> { let emacs = require("emacs")?; let init_file = require_option(self.directory.as_ref(), String::from("Emacs directory does not exist"))? .join("init.el") .require()?; if let Some(doom) = &self.doom { - return Emacs::update_doom(doom, run_type); + return Emacs::update_doom(doom, ctx); } print_separator("Emacs"); - let mut command = run_type.execute(&emacs); + let mut command = ctx.run_type().execute(&emacs); command .args(&["--batch", "--debug-init", "-l"])