diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-16 21:59:35 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-19 22:17:11 +0900 |
| commit | fd733a87364b877d5e66b4973bd61b5379ec4d61 (patch) | |
| tree | 64bd6c37ca1c33581a851eba22e4261bf5b62b49 /crates/shirabe/src/command/about_command.rs | |
| parent | 7f3171b14a89762b2f0c71969d7243f2297af7c9 (diff) | |
| download | php-shirabe-fd733a87364b877d5e66b4973bd61b5379ec4d61.tar.gz php-shirabe-fd733a87364b877d5e66b4973bd61b5379ec4d61.tar.zst php-shirabe-fd733a87364b877d5e66b4973bd61b5379ec4d61.zip | |
feat(command): implement Symfony Command
Diffstat (limited to 'crates/shirabe/src/command/about_command.rs')
| -rw-r--r-- | crates/shirabe/src/command/about_command.rs | 73 |
1 files changed, 53 insertions, 20 deletions
diff --git a/crates/shirabe/src/command/about_command.rs b/crates/shirabe/src/command/about_command.rs index 9b3fca5..1bfa89f 100644 --- a/crates/shirabe/src/command/about_command.rs +++ b/crates/shirabe/src/command/about_command.rs @@ -1,14 +1,24 @@ //! ref: composer/src/Composer/Command/AboutCommand.php +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; + +use crate::advisory::AuditConfig; use crate::command::BaseCommand; use crate::command::BaseCommandData; -use crate::command::HasBaseCommandData; +use crate::command::base_command::base_command_initialize; use crate::composer; -use crate::composer::ComposerHandle; +use crate::composer::PartialComposerHandle; +use crate::config::Config; +use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; #[derive(Debug)] pub struct AboutCommand { @@ -16,36 +26,59 @@ pub struct AboutCommand { } impl AboutCommand { - pub fn configure(&mut self) { - self.set_name("about") - .set_description("Shows a short information about Composer") - .set_help("<info>php composer.phar about</info>"); + pub fn new() -> Self { + let mut command = AboutCommand { + base_command_data: BaseCommandData::new(None), + }; + command + .configure() + .expect("AboutCommand::configure uses static, valid metadata"); + command + } +} + +impl Command for AboutCommand { + fn configure(&mut self) -> anyhow::Result<()> { + self.set_name("about")?; + self.set_description("Shows a short information about Composer"); + self.set_help("<info>php composer.phar about</info>"); + Ok(()) } - pub fn execute( + fn execute( &mut self, - input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, - output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, - ) -> i64 { + input: Rc<RefCell<dyn InputInterface>>, + output: Rc<RefCell<dyn OutputInterface>>, + ) -> anyhow::Result<i64> { let composer_version = composer::get_version(); let _ = (input, output); - self.get_io().write(&format!( + self.get_io().borrow().write(&format!( "<info>Composer - Dependency Manager for PHP - version {composer_version}</info>\n\ <comment>Composer is a dependency manager tracking local dependencies of your projects and libraries.\n\ See https://getcomposer.org/ for more information.</comment>" )); - 0 + Ok(0) } -} -impl HasBaseCommandData for AboutCommand { - fn base_command_data(&self) -> &BaseCommandData { - &self.base_command_data + fn initialize( + &mut self, + input: Rc<RefCell<dyn InputInterface>>, + output: Rc<RefCell<dyn OutputInterface>>, + ) -> anyhow::Result<()> { + base_command_initialize(self, input, output) } - fn base_command_data_mut(&mut self) -> &mut BaseCommandData { - &mut self.base_command_data + shirabe_external_packages::delegate_command_trait_impls_to_inner!(base_command_data); +} + +impl BaseCommand for AboutCommand { + fn command_data_mut( + &mut self, + ) -> &mut shirabe_external_packages::symfony::console::command::command::CommandData { + self.base_command_data.command_data_mut() } + + crate::delegate_base_command_trait_impls_to_inner!(base_command_data); } |
