diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-19 21:46:01 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-19 21:46:08 +0900 |
| commit | 5e31fa33c3b5cf726a57a063b8e7a070869250fe (patch) | |
| tree | 98522466966fa7df483cad174ab5fc03db39bc09 /crates/shirabe/src/console | |
| parent | c839244d8d09f3036ebfee8eef7eb6b147e593ab (diff) | |
| download | php-shirabe-5e31fa33c3b5cf726a57a063b8e7a070869250fe.tar.gz php-shirabe-5e31fa33c3b5cf726a57a063b8e7a070869250fe.tar.zst php-shirabe-5e31fa33c3b5cf726a57a063b8e7a070869250fe.zip | |
fix(compile): fix more random compile errors
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/console')
| -rw-r--r-- | crates/shirabe/src/console/application.rs | 32 | ||||
| -rw-r--r-- | crates/shirabe/src/console/html_output_formatter.rs | 16 | ||||
| -rw-r--r-- | crates/shirabe/src/console/input/mod.rs | 17 |
3 files changed, 49 insertions, 16 deletions
diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs index 13489fd..8d399a6 100644 --- a/crates/shirabe/src/console/application.rs +++ b/crates/shirabe/src/console/application.rs @@ -15,7 +15,9 @@ use shirabe_external_packages::symfony::component::console::input::input_definit use shirabe_external_packages::symfony::component::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::component::console::input::input_option::InputOption; use shirabe_external_packages::symfony::component::console::output::console_output_interface::ConsoleOutputInterface; -use shirabe_external_packages::symfony::component::console::output::output_interface::OutputInterface; +use shirabe_external_packages::symfony::component::console::output::output_interface::{ + self as output_interface, OutputInterface, +}; use shirabe_external_packages::symfony::component::console::single_command_application::SingleCommandApplication; use shirabe_external_packages::symfony::component::process::exception::process_timed_out_exception::ProcessTimedOutException; use shirabe_php_shim::{ @@ -202,7 +204,7 @@ impl Application { let mut helpers: Vec< Box<dyn shirabe_external_packages::symfony::component::console::helper::helper::Helper>, > = vec![]; - helpers.push(Box::new(QuestionHelper::new())); + helpers.push(Box::new(QuestionHelper)); let console_io = ConsoleIO::new(input, output, HelperSet::new(helpers)); self.io = Box::new(console_io); let io = &mut *self.io; @@ -339,10 +341,11 @@ impl Application { // Silently clobber any sudo credentials on the invoking user to avoid privilege escalations later on // ref. https://github.com/composer/composer/issues/5119 let _ = Silencer::call(|| { - shirabe_php_shim::exec(&format!( - "sudo -u \\#{} sudo -K > /dev/null 2>&1", - uid - )); + shirabe_php_shim::exec( + &format!("sudo -u \\#{} sudo -K > /dev/null 2>&1", uid), + None, + None, + ); Ok(()) }); } @@ -350,7 +353,7 @@ impl Application { // Silently clobber any remaining sudo leases on the current user as well to avoid privilege escalations let _ = Silencer::call(|| { - shirabe_php_shim::exec("sudo -K > /dev/null 2>&1"); + shirabe_php_shim::exec("sudo -K > /dev/null 2>&1", None, None); Ok(()) }); } @@ -608,6 +611,7 @@ impl Application { &map, composer .get_config() + .borrow() .get("vendor-dir") .as_string() .map(|s| s.to_string()), @@ -805,8 +809,8 @@ impl Application { let io = self.get_io(); let is_logic_or_error = exception.downcast_ref::<ShimLogicException>().is_some(); - if is_logic_or_error && output.get_verbosity() < OutputInterface::VERBOSITY_VERBOSE { - output.set_verbosity(OutputInterface::VERBOSITY_VERBOSE); + if is_logic_or_error && output.get_verbosity() < output_interface::VERBOSITY_VERBOSE { + output.set_verbosity(output_interface::VERBOSITY_VERBOSE); } Silencer::suppress(None); @@ -817,11 +821,17 @@ impl Application { let config = composer.get_config(); let min_space_free: f64 = 100.0 * 1024.0 * 1024.0; - let mut dir = config.get("home").as_string().unwrap_or("").to_string(); + let mut dir = config + .borrow_mut() + .get("home") + .as_string() + .unwrap_or("") + .to_string(); let df = disk_free_space(&dir); let mut hit = df.map(|d| d < min_space_free).unwrap_or(false); if !hit { dir = config + .borrow_mut() .get("vendor-dir") .as_string() .unwrap_or("") @@ -898,7 +908,7 @@ impl Application { .downcast_ref::<ProcessTimedOutException>() .is_some() { - io.write_error( + io.write_error3( "<error>The following exception is caused by a process timeout</error>", true, io_interface::QUIET, diff --git a/crates/shirabe/src/console/html_output_formatter.rs b/crates/shirabe/src/console/html_output_formatter.rs index c7be6ee..a0099e5 100644 --- a/crates/shirabe/src/console/html_output_formatter.rs +++ b/crates/shirabe/src/console/html_output_formatter.rs @@ -1,7 +1,7 @@ //! ref: composer/src/Composer/Console/HtmlOutputFormatter.php use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::preg::Preg; +use shirabe_external_packages::composer::pcre::preg::{CaptureKey, Preg}; use shirabe_external_packages::symfony::console::formatter::output_formatter::OutputFormatter; use shirabe_external_packages::symfony::console::formatter::output_formatter_style::OutputFormatterStyle; @@ -58,12 +58,18 @@ impl HtmlOutputFormatter { clear_escape_codes, clear_escape_codes ); - Preg::replace_callback(&pattern, |matches| self.format_html(matches), formatted).ok() + Preg::replace_callback(&pattern, |matches| self.format_html(matches), &formatted).ok() } - fn format_html(&self, matches: Vec<Option<String>>) -> String { - let codes_str = matches[1].as_deref().unwrap_or(""); - let content = matches[2].as_deref().unwrap_or(""); + fn format_html(&self, matches: &IndexMap<CaptureKey, String>) -> String { + let codes_str = matches + .get(&CaptureKey::ByIndex(1)) + .map(|s| s.as_str()) + .unwrap_or(""); + let content = matches + .get(&CaptureKey::ByIndex(2)) + .map(|s| s.as_str()) + .unwrap_or(""); let mut out = String::from("<span style=\""); for code_str in codes_str.split(';') { diff --git a/crates/shirabe/src/console/input/mod.rs b/crates/shirabe/src/console/input/mod.rs index f4451af..54f33a8 100644 --- a/crates/shirabe/src/console/input/mod.rs +++ b/crates/shirabe/src/console/input/mod.rs @@ -1,2 +1,19 @@ pub mod input_argument; pub mod input_option; + +pub enum InputDefinitionItem { + Argument(input_argument::InputArgument), + Option(input_option::InputOption), +} + +impl From<input_argument::InputArgument> for InputDefinitionItem { + fn from(value: input_argument::InputArgument) -> Self { + Self::Argument(value) + } +} + +impl From<input_option::InputOption> for InputDefinitionItem { + fn from(value: input_option::InputOption) -> Self { + Self::Option(value) + } +} |
