From 8c0b6942e04348b5e382c1da0043a9fa78ff1c19 Mon Sep 17 00:00:00 2001 From: jdx <216188+jdx@users.noreply.github.com> Date: Thu, 28 Nov 2024 13:08:38 -0600 Subject: [PATCH] fix: explicitly stop progress bars when exiting (#3272) Fixes #3267 --- schema/mise.json | 26 +++++++++++++++++--------- src/main.rs | 4 ++++ src/ui/multi_progress_report.rs | 6 ++++++ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/schema/mise.json b/schema/mise.json index 61f8cdcc2..09ea89779 100644 --- a/schema/mise.json +++ b/schema/mise.json @@ -942,16 +942,24 @@ "description": "config file for mise version manager (mise.toml)", "properties": { "alias": { + "description": "custom shorthands", + "type": "object", "additionalProperties": { - "additionalProperties": { - "description": "version alias points to", - "type": "string" - }, - "description": "plugin to set aliases for", - "type": "object" - }, - "description": "custom shorthands for versions", - "type": "object" + "oneOf": [ + { + "description": "where the alias goes", + "type": "string" + }, + { + "description": "tool to set aliases for", + "type": "object", + "additionalProperties": { + "description": "version alias points to", + "type": "string" + } + } + ] + } }, "env": { "oneOf": [ diff --git a/src/main.rs b/src/main.rs index e4b51ceca..ff4a49713 100644 --- a/src/main.rs +++ b/src/main.rs @@ -69,6 +69,7 @@ mod versions_host; pub(crate) use crate::exit::exit; pub(crate) use crate::toolset::install_state; +use crate::ui::multi_progress_report::MultiProgressReport; fn main() -> eyre::Result<()> { color_eyre::install()?; @@ -79,6 +80,9 @@ fn main() -> eyre::Result<()> { Err(err) => handle_err(err), }?; }); + if let Some(mpr) = MultiProgressReport::try_get() { + mpr.stop()?; + } Ok(()) } diff --git a/src/ui/multi_progress_report.rs b/src/ui/multi_progress_report.rs index 05ea06f53..ea1ca9a4a 100644 --- a/src/ui/multi_progress_report.rs +++ b/src/ui/multi_progress_report.rs @@ -70,6 +70,12 @@ impl MultiProgressReport { None => f(), } } + pub fn stop(&self) -> eyre::Result<()> { + if let Some(mp) = &self.mp { + mp.clear()?; + } + Ok(()) + } } #[cfg(test)]