From 6051927c8fa32cfffa102d2a170c5a6cf747a1b9 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 9 Aug 2026 11:19:03 +0900 Subject: refactor(symfony-console): extract symfony/console into the shirabe-symfony-console crate Move `Symfony\Component\Console` out of shirabe-external-packages and into its own crate, so the path is `shirabe_symfony_console::application::Application` instead of `shirabe_external_packages::symfony::console::application::Application`. The `delegate_to_inner!` and `delegate_command_trait_impls_to_inner!` macros move with it. Co-Authored-By: Claude Opus 5 (1M context) --- .../src/symfony/console/helper/table_cell.rs | 99 ---------------------- 1 file changed, 99 deletions(-) delete mode 100644 crates/shirabe-external-packages/src/symfony/console/helper/table_cell.rs (limited to 'crates/shirabe-external-packages/src/symfony/console/helper/table_cell.rs') diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/table_cell.rs b/crates/shirabe-external-packages/src/symfony/console/helper/table_cell.rs deleted file mode 100644 index c899e5f7..00000000 --- a/crates/shirabe-external-packages/src/symfony/console/helper/table_cell.rs +++ /dev/null @@ -1,99 +0,0 @@ -//! ref: composer/vendor/symfony/console/Helper/TableCell.php - -use crate::symfony::console::exception::invalid_argument_exception::InvalidArgumentException; -use crate::symfony::console::helper::table_cell_style::TableCellStyle; -use indexmap::IndexMap; - -/// A `TableCell` option value: an integer span, a `TableCellStyle`, or null. -#[derive(Debug, Clone)] -pub enum TableCellOption { - Int(i64), - Style(std::rc::Rc), - Null, -} - -#[derive(Debug, Clone)] -pub struct TableCell { - pub(crate) value: String, - options: IndexMap, -} - -impl TableCell { - pub fn new( - value: &str, - options: IndexMap, - ) -> Result { - let mut this_options: IndexMap = IndexMap::new(); - this_options.insert("rowspan".to_string(), TableCellOption::Int(1)); - this_options.insert("colspan".to_string(), TableCellOption::Int(1)); - this_options.insert("style".to_string(), TableCellOption::Null); - - // check option names - let diff: Vec = options - .keys() - .filter(|key| !this_options.contains_key(*key)) - .cloned() - .collect(); - if !diff.is_empty() { - return Err(InvalidArgumentException::new(format!( - "The TableCell does not support the following options: '{}'.", - diff.join("', '"), - ))); - } - - if let Some(style) = options.get("style") - && !matches!(style, TableCellOption::Style(_)) - && !matches!(style, TableCellOption::Null) - { - return Err(InvalidArgumentException::new( - "The style option must be an instance of \"TableCellStyle\".".to_string(), - )); - } - - for (key, option) in options { - this_options.insert(key, option); - } - - Ok(Self { - value: value.to_string(), - options: this_options, - }) - } - - /// Two-argument constructor (`__construct(string $value, array $options)`). - /// - /// The options used by the Table helper are internally controlled, so a malformed-option - /// error here would be a programming bug rather than a recoverable condition. - pub fn new2(value: &str, options: IndexMap) -> Self { - Self::new(value, options).expect("TableCell options built internally are always valid") - } - - /// Gets number of colspan. - pub fn get_colspan(&self) -> i64 { - match self.options["colspan"] { - TableCellOption::Int(colspan) => colspan, - _ => 0, - } - } - - /// Gets number of rowspan. - pub fn get_rowspan(&self) -> i64 { - match self.options["rowspan"] { - TableCellOption::Int(rowspan) => rowspan, - _ => 0, - } - } - - pub fn get_style(&self) -> Option> { - match &self.options["style"] { - TableCellOption::Style(style) => Some(style.clone()), - _ => None, - } - } -} - -impl std::fmt::Display for TableCell { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.value) - } -} -- cgit v1.3.1-4-g156e