From 1e44f5723e4c0e0903d00a61f254901e612fe5e1 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 12 Jun 2026 01:01:35 +0900 Subject: feat(symfony-console): port Symfony Console and make the workspace compile Co-Authored-By: Claude Opus 4.8 --- crates/shirabe/src/console/html_output_formatter.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'crates/shirabe/src/console/html_output_formatter.rs') diff --git a/crates/shirabe/src/console/html_output_formatter.rs b/crates/shirabe/src/console/html_output_formatter.rs index a2158fa..b516c83 100644 --- a/crates/shirabe/src/console/html_output_formatter.rs +++ b/crates/shirabe/src/console/html_output_formatter.rs @@ -3,7 +3,8 @@ use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_external_packages::symfony::console::formatter::OutputFormatter; -use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyle; +use shirabe_external_packages::symfony::console::formatter::OutputFormatterInterface; +use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyleInterface; #[derive(Debug)] pub struct HtmlOutputFormatter { @@ -41,14 +42,19 @@ impl HtmlOutputFormatter { //8 => "conceal" ]; - pub fn new(styles: IndexMap) -> Self { + pub fn new(styles: IndexMap>) -> Self { Self { inner: OutputFormatter::new(true, styles), } } - pub fn format(&self, message: Option<&str>) -> Option { - let formatted = self.inner.format(message.unwrap_or("")); + pub fn format(&mut self, message: Option<&str>) -> anyhow::Result> { + let formatted = self.inner.format(message)?; + + let formatted = match formatted { + Some(formatted) => formatted, + None => return Ok(None), + }; let clear_escape_codes = "(?:39|49|0|22|24|25|27|28)"; let pattern = format!( @@ -56,7 +62,11 @@ impl HtmlOutputFormatter { clear_escape_codes, clear_escape_codes ); - Preg::replace_callback(&pattern, |matches| self.format_html(matches), &formatted).ok() + Ok(Some(Preg::replace_callback( + &pattern, + |matches| self.format_html(matches), + &formatted, + )?)) } fn format_html(&self, matches: &IndexMap) -> String { -- cgit v1.3.1