diff --git a/src/runner.rs b/src/runner.rs index 210212e95..c27c48ce9 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -7,8 +7,9 @@ use tracing::debug; use crate::ctrlc; use crate::error::{DryRun, MissingSudo, SkipStep}; use crate::execution_context::ExecutionContext; +use crate::report::{Report, StepResult}; use crate::step::Step; -use crate::terminal::{print_error, print_warning, should_retry}; +use crate::terminal::{print_error, print_separator, print_warning, should_retry}; pub enum StepResult { Success, @@ -53,6 +54,14 @@ impl<'a> Runner<'a> { where K: Into> + Debug, F: Fn() -> Result<()>, + { + todo!("This function will be removed and `execute_2` will be renamed to `execute`") + } + + pub fn execute_2(&mut self, step: Step, key: M, func: F) -> Result<()> + where + F: Fn(&ExecutionContext, &dyn Fn()) -> Result<()>, + M: Into> + Debug, { if !self.ctx.config().should_run(step) { return Ok(()); @@ -61,12 +70,14 @@ impl<'a> Runner<'a> { let key: Cow<'a, str> = key.into(); debug!("Step {:?}", key); - // alter the `func` to put it in a span + let confirm_run = || self.confirm_run(&key); + + // Alter the `func` to put it in a span, and add `ctx` and `confirm_run` let func = || { let span = tracing::span!(parent: tracing::Span::none(), tracing::Level::TRACE, "step", step = ?step, key = %key); let _guard = span.enter(); - func() + func(self.ctx, &confirm_run) }; loop { @@ -121,6 +132,10 @@ impl<'a> Runner<'a> { Ok(()) } + fn confirm_run(&self, key: &str) { + print_separator(key); + } + pub fn report(&self) -> &Report<'_> { &self.report } diff --git a/src/step.rs b/src/step.rs index a209b0e50..8746faf62 100644 --- a/src/step.rs +++ b/src/step.rs @@ -677,7 +677,7 @@ impl Step { runner.execute(*self, "yadm", || unix::run_yadm(ctx))? } Yarn => runner.execute(*self, "yarn", || node::run_yarn_upgrade(ctx))?, - Yazi => runner.execute(*self, "Yazi packages", || generic::run_yazi(ctx))?, + Yazi => runner.execute_2(*self, "Yazi packages", generic::run_yazi)?, Zigup => runner.execute(*self, "zigup", || generic::run_zigup(ctx))?, Zvm => runner.execute(*self, "ZVM", || generic::run_zvm(ctx))?, } diff --git a/src/steps/generic.rs b/src/steps/generic.rs index 55198b059..a85e4ec42 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -1736,10 +1736,10 @@ pub fn run_jetbrains_webstorm(ctx: &ExecutionContext) -> Result<()> { run_jetbrains_ide(ctx, require_one(["webstorm", "webstorm-eap"])?, "WebStorm") } -pub fn run_yazi(ctx: &ExecutionContext) -> Result<()> { +pub fn run_yazi(ctx: &ExecutionContext, confirm_run: &dyn Fn()) -> Result<()> { let ya = require("ya")?; - print_separator("Yazi packages"); + confirm_run(); ctx.execute(ya).args(["pkg", "upgrade"]).status_checked() }