From a9bb49c7d685dd82feaf4050f756fdf590315200 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 17 May 2026 13:56:15 +0900 Subject: fix(compile): implement abstract class traits across all types Implement BaseCommand trait and other abstract class traits across all command, downloader, io, package, and VCS driver types. Also fix trait method signatures for composer_mut and io_mut to return mutable references to Option rather than Option of mutable references. --- crates/shirabe/src/command/about_command.rs | 32 +++++++- crates/shirabe/src/command/archive_command.rs | 31 +++++++- crates/shirabe/src/command/audit_command.rs | 35 +++++++- crates/shirabe/src/command/base_command.rs | 4 +- crates/shirabe/src/command/bump_command.rs | 32 +++++++- .../src/command/check_platform_reqs_command.rs | 33 +++++++- crates/shirabe/src/command/clear_cache_command.rs | 33 +++++++- crates/shirabe/src/command/config_command.rs | 90 ++++++++++++++++++++- .../shirabe/src/command/create_project_command.rs | 32 +++++++- crates/shirabe/src/command/depends_command.rs | 38 ++++++++- crates/shirabe/src/command/diagnose_command.rs | 33 +++++++- .../shirabe/src/command/dump_autoload_command.rs | 33 +++++++- crates/shirabe/src/command/exec_command.rs | 33 +++++++- crates/shirabe/src/command/fund_command.rs | 33 +++++++- crates/shirabe/src/command/global_command.rs | 33 +++++++- crates/shirabe/src/command/home_command.rs | 33 +++++++- crates/shirabe/src/command/init_command.rs | 33 +++++++- crates/shirabe/src/command/install_command.rs | 33 +++++++- crates/shirabe/src/command/licenses_command.rs | 33 +++++++- crates/shirabe/src/command/outdated_command.rs | 33 +++++++- crates/shirabe/src/command/prohibits_command.rs | 38 ++++++++- crates/shirabe/src/command/reinstall_command.rs | 33 +++++++- crates/shirabe/src/command/remove_command.rs | 33 +++++++- crates/shirabe/src/command/repository_command.rs | 92 +++++++++++++++++++++- crates/shirabe/src/command/require_command.rs | 33 +++++++- crates/shirabe/src/command/run_script_command.rs | 34 +++++++- crates/shirabe/src/command/script_alias_command.rs | 35 +++++++- crates/shirabe/src/command/search_command.rs | 34 +++++++- crates/shirabe/src/command/self_update_command.rs | 31 +++++++- crates/shirabe/src/command/show_command.rs | 32 +++++++- crates/shirabe/src/command/status_command.rs | 33 +++++++- crates/shirabe/src/command/suggests_command.rs | 37 ++++++++- crates/shirabe/src/command/update_command.rs | 30 ++++++- crates/shirabe/src/command/validate_command.rs | 32 +++++++- 34 files changed, 1178 insertions(+), 39 deletions(-) (limited to 'crates/shirabe/src/command') diff --git a/crates/shirabe/src/command/about_command.rs b/crates/shirabe/src/command/about_command.rs index 3b16b0e..583482b 100644 --- a/crates/shirabe/src/command/about_command.rs +++ b/crates/shirabe/src/command/about_command.rs @@ -2,11 +2,15 @@ use crate::command::base_command::BaseCommand; use crate::composer::Composer; +use crate::io::io_interface::IOInterface; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; pub struct AboutCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl AboutCommand { @@ -29,3 +33,29 @@ impl AboutCommand { 0 } } + +impl BaseCommand for AboutCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/archive_command.rs b/crates/shirabe/src/command/archive_command.rs index 867b010..1a85df4 100644 --- a/crates/shirabe/src/command/archive_command.rs +++ b/crates/shirabe/src/command/archive_command.rs @@ -4,6 +4,7 @@ use std::any::Any; use anyhow::Result; use shirabe_external_packages::composer::pcre::preg::Preg; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use shirabe_php_shim::{LogicException, get_debug_type}; @@ -33,7 +34,9 @@ use crate::util::process_executor::ProcessExecutor; #[derive(Debug)] pub struct ArchiveCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl CompletionTrait for ArchiveCommand {} @@ -319,3 +322,29 @@ impl ArchiveCommand { Ok(Some(package.into_complete())) } } + +impl BaseCommand for ArchiveCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/audit_command.rs b/crates/shirabe/src/command/audit_command.rs index 7fb6c5f..2331f8d 100644 --- a/crates/shirabe/src/command/audit_command.rs +++ b/crates/shirabe/src/command/audit_command.rs @@ -5,13 +5,16 @@ use crate::advisory::auditor::Auditor; use crate::command::base_command::BaseCommand; use crate::composer::Composer; use crate::console::input::input_option::InputOption; +use crate::io::io_interface::IOInterface; use crate::package::package_interface::PackageInterface; use crate::repository::installed_repository::InstalledRepository; use crate::repository::repository_set::RepositorySet; use crate::repository::repository_utils::RepositoryUtils; use anyhow::Result; -use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; +use shirabe_external_packages::symfony::{ + component::console::command::command::Command, console::input::input_interface::InputInterface, +}; use shirabe_php_shim::{ InvalidArgumentException, PhpMixed, UnexpectedValueException, array_fill_keys, array_merge, implode, in_array, @@ -19,7 +22,9 @@ use shirabe_php_shim::{ #[derive(Debug)] pub struct AuditCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl AuditCommand { @@ -154,3 +159,29 @@ impl AuditCommand { Ok(installed_repo.get_packages()) } } + +impl BaseCommand for AuditCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/base_command.rs b/crates/shirabe/src/command/base_command.rs index 7f9a860..c9f79b7 100644 --- a/crates/shirabe/src/command/base_command.rs +++ b/crates/shirabe/src/command/base_command.rs @@ -38,9 +38,9 @@ pub trait BaseCommand { fn inner(&self) -> &Command; fn inner_mut(&mut self) -> &mut Command; fn composer(&self) -> Option<&Composer>; - fn composer_mut(&mut self) -> Option<&mut Composer>; + fn composer_mut(&mut self) -> &mut Option; fn io(&self) -> Option<&dyn IOInterface>; - fn io_mut(&mut self) -> Option<&mut dyn IOInterface>; + fn io_mut(&mut self) -> &mut Option>; /// Gets the application instance for this command. fn get_application(&self) -> Result { diff --git a/crates/shirabe/src/command/bump_command.rs b/crates/shirabe/src/command/bump_command.rs index ddb17c2..0382246 100644 --- a/crates/shirabe/src/command/bump_command.rs +++ b/crates/shirabe/src/command/bump_command.rs @@ -2,12 +2,14 @@ use anyhow::Result; use shirabe_external_packages::composer::pcre::preg::Preg; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use shirabe_php_shim::{PhpMixed, file_get_contents, file_put_contents, is_writable, strtolower}; use crate::command::base_command::BaseCommand; use crate::command::completion_trait::CompletionTrait; +use crate::composer::Composer; use crate::console::input::input_argument::InputArgument; use crate::console::input::input_option::InputOption; use crate::factory::Factory; @@ -23,7 +25,9 @@ use crate::util::silencer::Silencer; #[derive(Debug)] pub struct BumpCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl CompletionTrait for BumpCommand {} @@ -368,3 +372,29 @@ impl BumpCommand { } } } + +impl BaseCommand for BumpCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/check_platform_reqs_command.rs b/crates/shirabe/src/command/check_platform_reqs_command.rs index fcf10aa..62cde82 100644 --- a/crates/shirabe/src/command/check_platform_reqs_command.rs +++ b/crates/shirabe/src/command/check_platform_reqs_command.rs @@ -2,13 +2,16 @@ use anyhow::Result; use indexmap::IndexMap; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use shirabe_php_shim::{PhpMixed, strip_tags}; use shirabe_semver::constraint::constraint::Constraint; use crate::command::base_command::BaseCommand; +use crate::composer::Composer; use crate::console::input::input_option::InputOption; +use crate::io::io_interface::IOInterface; use crate::json::json_file::JsonFile; use crate::package::link::Link; use crate::repository::installed_repository::InstalledRepository; @@ -25,7 +28,9 @@ struct CheckResult { #[derive(Debug)] pub struct CheckPlatformReqsCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl CheckPlatformReqsCommand { @@ -316,3 +321,29 @@ impl CheckPlatformReqsCommand { } } } + +impl BaseCommand for CheckPlatformReqsCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/clear_cache_command.rs b/crates/shirabe/src/command/clear_cache_command.rs index 06026a4..1d49502 100644 --- a/crates/shirabe/src/command/clear_cache_command.rs +++ b/crates/shirabe/src/command/clear_cache_command.rs @@ -2,15 +2,20 @@ use crate::cache::Cache; use crate::command::base_command::BaseCommand; +use crate::composer::Composer; use crate::console::input::input_option::InputOption; use crate::factory::Factory; +use crate::io::io_interface::IOInterface; use indexmap::IndexMap; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; #[derive(Debug)] pub struct ClearCacheCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl ClearCacheCommand { @@ -116,3 +121,29 @@ impl ClearCacheCommand { Ok(0) } } + +impl BaseCommand for ClearCacheCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs index 5237b62..62e630a 100644 --- a/crates/shirabe/src/command/config_command.rs +++ b/crates/shirabe/src/command/config_command.rs @@ -3,6 +3,7 @@ use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::component::console::completion::completion_input::CompletionInput; use shirabe_external_packages::symfony::component::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::component::console::input::input_option::InputOption; @@ -17,7 +18,9 @@ use shirabe_php_shim::{ }; use crate::advisory::auditor::Auditor; +use crate::command::base_command::BaseCommand; use crate::command::base_config_command::BaseConfigCommand; +use crate::composer::Composer; use crate::config::Config; use crate::config::json_config_source::JsonConfigSource; use crate::console::input::input_argument::InputArgument; @@ -32,7 +35,14 @@ use shirabe_semver::version_parser::VersionParser; #[derive(Debug)] pub struct ConfigCommand { - inner: BaseConfigCommand, + inner: Command, + composer: Option, + io: Option>, + + config: Option, + config_file: Option, + config_source: Option, + pub(crate) auth_config_file: Option, pub(crate) auth_config_source: Option, } @@ -2170,3 +2180,81 @@ fn key_first_key(value: &PhpMixed) -> Option { } None } + +impl BaseCommand for ConfigCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> Option<&mut Composer> { + self.composer.as_mut() + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_ref() + } + + fn io_mut(&mut self) -> Option<&mut dyn IOInterface> { + self.io.as_mut() + } +} + +impl BaseCommand for ConfigCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} + +impl BaseConfigCommand for ConfigCommand { + fn config(&self) -> Option<&Config> { + self.config.as_ref() + } + + fn config_mut(&mut self) -> Option<&mut Config> { + self.config.as_mut() + } + + fn config_file(&self) -> Option<&JsonFile> { + self.config_file.as_ref() + } + + fn config_file_mut(&mut self) -> Option<&mut JsonFile> { + self.config_file.as_mut() + } + + fn config_source(&self) -> Option<&JsonConfigSource> { + self.config_source.as_ref() + } + + fn config_source_mut(&mut self) -> Option<&mut JsonConfigSource> { + self.config_source.as_mut() + } +} diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs index c649848..c0902d4 100644 --- a/crates/shirabe/src/command/create_project_command.rs +++ b/crates/shirabe/src/command/create_project_command.rs @@ -3,6 +3,7 @@ use anyhow::Result; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_external_packages::seld::signal::signal_handler::SignalHandler; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::component::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::component::console::output::output_interface::OutputInterface; use shirabe_external_packages::symfony::component::finder::finder::Finder; @@ -48,7 +49,10 @@ use crate::util::process_executor::ProcessExecutor; /// Install a package as new project into new directory. #[derive(Debug)] pub struct CreateProjectCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, + /// @var SuggestedPackagesReporter pub(crate) suggested_packages_reporter: Option, } @@ -895,3 +899,29 @@ impl CreateProjectCommand { self.inner.create_audit_config(config, input) } } + +impl BaseCommand for CreateProjectCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/depends_command.rs b/crates/shirabe/src/command/depends_command.rs index 9ec3dde..f83fe00 100644 --- a/crates/shirabe/src/command/depends_command.rs +++ b/crates/shirabe/src/command/depends_command.rs @@ -8,7 +8,7 @@ use shirabe_external_packages::symfony::console::input::input_interface::InputIn use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; pub struct DependsCommand { - inner: BaseDependencyCommand, + colors: Vec, } impl CompletionTrait for DependsCommand {} @@ -58,3 +58,39 @@ impl DependsCommand { self.inner.do_execute(input, output) } } + +impl BaseCommand for DependsCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} + +impl BaseDependencyCommand for DependsCommand { + fn colors(&self) -> &[String] { + &self.colors + } + + fn colors_mut(&mut self) -> &mut [String] { + &mut self.colors + } +} diff --git a/crates/shirabe/src/command/diagnose_command.rs b/crates/shirabe/src/command/diagnose_command.rs index 07e367f..23c0cd0 100644 --- a/crates/shirabe/src/command/diagnose_command.rs +++ b/crates/shirabe/src/command/diagnose_command.rs @@ -4,6 +4,7 @@ use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_external_packages::composer::xdebug_handler::xdebug_handler::XdebugHandler; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::component::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::component::console::output::output_interface::OutputInterface; use shirabe_external_packages::symfony::component::process::executable_finder::ExecutableFinder; @@ -25,6 +26,7 @@ use crate::config::Config; use crate::downloader::transport_exception::TransportException; use crate::factory::Factory; use crate::io::buffer_io::BufferIO; +use crate::io::io_interface::IOInterface; use crate::io::null_io::NullIO; use crate::json::json_file::JsonFile; use crate::json::json_validation_exception::JsonValidationException; @@ -51,7 +53,10 @@ use crate::util::process_executor::ProcessExecutor; #[derive(Debug)] pub struct DiagnoseCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, + pub(crate) http_downloader: Option, pub(crate) process: Option, pub(crate) exit_code: i64, @@ -1364,3 +1369,29 @@ impl DiagnoseCommand { PhpMixed::Bool(true) } } + +impl BaseCommand for DiagnoseCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/dump_autoload_command.rs b/crates/shirabe/src/command/dump_autoload_command.rs index 295f1c0..471b353 100644 --- a/crates/shirabe/src/command/dump_autoload_command.rs +++ b/crates/shirabe/src/command/dump_autoload_command.rs @@ -1,18 +1,23 @@ //! ref: composer/src/Composer/Command/DumpAutoloadCommand.php use anyhow::Result; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use shirabe_php_shim::{InvalidArgumentException, PhpMixed, file_exists}; use crate::command::base_command::BaseCommand; +use crate::composer::Composer; use crate::console::input::input_option::InputOption; +use crate::io::io_interface::IOInterface; use crate::plugin::command_event::CommandEvent; use crate::plugin::plugin_events::PluginEvents; #[derive(Debug)] pub struct DumpAutoloadCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl DumpAutoloadCommand { @@ -197,3 +202,29 @@ impl DumpAutoloadCommand { Ok(0) } } + +impl BaseCommand for DumpAutoloadCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/exec_command.rs b/crates/shirabe/src/command/exec_command.rs index 5602e85..82c90bc 100644 --- a/crates/shirabe/src/command/exec_command.rs +++ b/crates/shirabe/src/command/exec_command.rs @@ -1,17 +1,22 @@ //! ref: composer/src/Composer/Command/ExecCommand.php use anyhow::Result; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use shirabe_php_shim::{PhpMixed, RuntimeException, basename, chdir, getcwd, glob}; use crate::command::base_command::BaseCommand; +use crate::composer::Composer; use crate::console::input::input_argument::InputArgument; use crate::console::input::input_option::InputOption; +use crate::io::io_interface::IOInterface; #[derive(Debug)] pub struct ExecCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl ExecCommand { @@ -186,3 +191,29 @@ impl ExecCommand { Ok(binaries) } } + +impl BaseCommand for ExecCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/fund_command.rs b/crates/shirabe/src/command/fund_command.rs index 398efd9..0d0c2ec 100644 --- a/crates/shirabe/src/command/fund_command.rs +++ b/crates/shirabe/src/command/fund_command.rs @@ -5,6 +5,7 @@ use std::any::Any; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::formatter::output_formatter::OutputFormatter; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; @@ -12,7 +13,9 @@ use shirabe_php_shim::PhpMixed; use shirabe_semver::constraint::match_all_constraint::MatchAllConstraint; use crate::command::base_command::BaseCommand; +use crate::composer::Composer; use crate::console::input::input_option::InputOption; +use crate::io::io_interface::IOInterface; use crate::json::json_file::JsonFile; use crate::package::alias_package::AliasPackage; use crate::package::base_package::BasePackage; @@ -21,7 +24,9 @@ use crate::repository::composite_repository::CompositeRepository; #[derive(Debug)] pub struct FundCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl FundCommand { @@ -201,3 +206,29 @@ impl FundCommand { Ok(()) } } + +impl BaseCommand for FundCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/global_command.rs b/crates/shirabe/src/command/global_command.rs index 695232c..a5423f5 100644 --- a/crates/shirabe/src/command/global_command.rs +++ b/crates/shirabe/src/command/global_command.rs @@ -4,6 +4,7 @@ use std::path::Path; use anyhow::Result; use shirabe_external_packages::composer::pcre::preg::Preg; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::completion::completion_input::CompletionInput; use shirabe_external_packages::symfony::console::completion::completion_suggestions::CompletionSuggestions; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; @@ -12,14 +13,18 @@ use shirabe_external_packages::symfony::console::output::output_interface::Outpu use shirabe_php_shim::{LogicException, RuntimeException, chdir}; use crate::command::base_command::BaseCommand; +use crate::composer::Composer; use crate::console::input::input_argument::InputArgument; use crate::factory::Factory; +use crate::io::io_interface::IOInterface; use crate::util::filesystem::Filesystem; use crate::util::platform::Platform; #[derive(Debug)] pub struct GlobalCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl GlobalCommand { @@ -157,3 +162,29 @@ impl GlobalCommand { true } } + +impl BaseCommand for GlobalCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/home_command.rs b/crates/shirabe/src/command/home_command.rs index 142f868..dd8a81c 100644 --- a/crates/shirabe/src/command/home_command.rs +++ b/crates/shirabe/src/command/home_command.rs @@ -1,14 +1,17 @@ //! ref: composer/src/Composer/Command/HomeCommand.php use anyhow::Result; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use shirabe_php_shim::{FILTER_VALIDATE_URL, filter_var}; use crate::command::base_command::BaseCommand; use crate::command::completion_trait::CompletionTrait; +use crate::composer::Composer; use crate::console::input::input_argument::InputArgument; use crate::console::input::input_option::InputOption; +use crate::io::io_interface::IOInterface; use crate::package::complete_package_interface::CompletePackageInterface; use crate::repository::repository_factory::RepositoryFactory; use crate::repository::repository_interface::RepositoryInterface; @@ -18,7 +21,9 @@ use crate::util::process_executor::ProcessExecutor; #[derive(Debug)] pub struct HomeCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl CompletionTrait for HomeCommand {} @@ -216,3 +221,29 @@ impl HomeCommand { )) } } + +impl BaseCommand for HomeCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs index e61b7a6..d8f0113 100644 --- a/crates/shirabe/src/command/init_command.rs +++ b/crates/shirabe/src/command/init_command.rs @@ -4,6 +4,7 @@ use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_external_packages::composer::spdx_licenses::spdx_licenses::SpdxLicenses; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::component::console::helper::formatter_helper::FormatterHelper; use shirabe_external_packages::symfony::component::console::input::array_input::ArrayInput; use shirabe_external_packages::symfony::component::console::input::input_interface::InputInterface; @@ -19,6 +20,7 @@ use shirabe_php_shim::{ use crate::command::base_command::BaseCommand; use crate::command::completion_trait::CompletionTrait; use crate::command::package_discovery_trait::PackageDiscoveryTrait; +use crate::composer::Composer; use crate::console::input::input_option::InputOption; use crate::factory::Factory; use crate::io::io_interface::IOInterface; @@ -34,7 +36,10 @@ use crate::util::silencer::Silencer; #[derive(Debug)] pub struct InitCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, + /// @var array git_config: Option>, } @@ -1152,3 +1157,29 @@ impl InitCommand { None } } + +impl BaseCommand for InitCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/install_command.rs b/crates/shirabe/src/command/install_command.rs index 264b58c..04d630b 100644 --- a/crates/shirabe/src/command/install_command.rs +++ b/crates/shirabe/src/command/install_command.rs @@ -1,6 +1,7 @@ //! ref: composer/src/Composer/Command/InstallCommand.php use anyhow::Result; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use shirabe_php_shim::PhpMixed; @@ -8,16 +9,20 @@ use shirabe_php_shim::PhpMixed; use crate::advisory::auditor::Auditor; use crate::command::base_command::BaseCommand; use crate::command::completion_trait::CompletionTrait; +use crate::composer::Composer; use crate::console::input::input_argument::InputArgument; use crate::console::input::input_option::InputOption; use crate::installer::Installer; +use crate::io::io_interface::IOInterface; use crate::plugin::command_event::CommandEvent; use crate::plugin::plugin_events::PluginEvents; use crate::util::http_downloader::HttpDownloader; #[derive(Debug)] pub struct InstallCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl CompletionTrait for InstallCommand {} @@ -174,3 +179,29 @@ impl InstallCommand { install.run() } } + +impl BaseCommand for InstallCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/licenses_command.rs b/crates/shirabe/src/command/licenses_command.rs index ddb7b32..4cebc07 100644 --- a/crates/shirabe/src/command/licenses_command.rs +++ b/crates/shirabe/src/command/licenses_command.rs @@ -4,6 +4,7 @@ use std::any::Any; use anyhow::Result; use indexmap::IndexMap; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::formatter::output_formatter::OutputFormatter; use shirabe_external_packages::symfony::console::helper::table::Table; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; @@ -12,7 +13,9 @@ use shirabe_external_packages::symfony::console::style::symfony_style::SymfonySt use shirabe_php_shim::{PhpMixed, RuntimeException, UnexpectedValueException}; use crate::command::base_command::BaseCommand; +use crate::composer::Composer; use crate::console::input::input_option::InputOption; +use crate::io::io_interface::IOInterface; use crate::json::json_file::JsonFile; use crate::package::complete_package::CompletePackage; use crate::package::complete_package_interface::CompletePackageInterface; @@ -24,7 +27,9 @@ use crate::util::package_sorter::PackageSorter; #[derive(Debug)] pub struct LicensesCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl LicensesCommand { @@ -281,3 +286,29 @@ impl LicensesCommand { Ok(0) } } + +impl BaseCommand for LicensesCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/outdated_command.rs b/crates/shirabe/src/command/outdated_command.rs index ed927b7..1a19931 100644 --- a/crates/shirabe/src/command/outdated_command.rs +++ b/crates/shirabe/src/command/outdated_command.rs @@ -2,10 +2,13 @@ use crate::command::base_command::BaseCommand; use crate::command::completion_trait::CompletionTrait; +use crate::composer::Composer; use crate::console::input::input_argument::InputArgument; use crate::console::input::input_option::InputOption; +use crate::io::io_interface::IOInterface; use anyhow::Result; use indexmap::IndexMap; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::input::array_input::ArrayInput; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; @@ -13,7 +16,9 @@ use shirabe_php_shim::PhpMixed; #[derive(Debug)] pub struct OutdatedCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl CompletionTrait for OutdatedCommand {} @@ -133,3 +138,29 @@ impl OutdatedCommand { true } } + +impl BaseCommand for OutdatedCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/prohibits_command.rs b/crates/shirabe/src/command/prohibits_command.rs index accfcf0..c8aa89d 100644 --- a/crates/shirabe/src/command/prohibits_command.rs +++ b/crates/shirabe/src/command/prohibits_command.rs @@ -8,7 +8,7 @@ use shirabe_external_packages::symfony::console::input::input_interface::InputIn use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; pub struct ProhibitsCommand { - inner: BaseDependencyCommand, + colors: Vec, } impl CompletionTrait for ProhibitsCommand {} @@ -65,3 +65,39 @@ impl ProhibitsCommand { self.inner.do_execute(input, output, true) } } + +impl BaseCommand for ProhibitsCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} + +impl BaseDependencyCommand for ProhibitsCommand { + fn colors(&self) -> &[String] { + &self.colors + } + + fn colors_mut(&mut self) -> &mut [String] { + &mut self.colors + } +} diff --git a/crates/shirabe/src/command/reinstall_command.rs b/crates/shirabe/src/command/reinstall_command.rs index 3fb26a2..e0a8843 100644 --- a/crates/shirabe/src/command/reinstall_command.rs +++ b/crates/shirabe/src/command/reinstall_command.rs @@ -4,17 +4,20 @@ use std::any::Any; use anyhow::Result; use shirabe_external_packages::composer::pcre::preg::Preg; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use shirabe_php_shim::InvalidArgumentException; use crate::command::base_command::BaseCommand; use crate::command::completion_trait::CompletionTrait; +use crate::composer::Composer; use crate::console::input::input_argument::InputArgument; use crate::console::input::input_option::InputOption; use crate::dependency_resolver::operation::install_operation::InstallOperation; use crate::dependency_resolver::operation::uninstall_operation::UninstallOperation; use crate::dependency_resolver::transaction::Transaction; +use crate::io::io_interface::IOInterface; use crate::package::alias_package::AliasPackage; use crate::package::base_package::BasePackage; use crate::plugin::command_event::CommandEvent; @@ -24,7 +27,9 @@ use crate::util::platform::Platform; #[derive(Debug)] pub struct ReinstallCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl CompletionTrait for ReinstallCommand {} @@ -264,3 +269,29 @@ impl ReinstallCommand { Ok(0) } } + +impl BaseCommand for ReinstallCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/remove_command.rs b/crates/shirabe/src/command/remove_command.rs index b7f8378..da1da09 100644 --- a/crates/shirabe/src/command/remove_command.rs +++ b/crates/shirabe/src/command/remove_command.rs @@ -2,6 +2,7 @@ use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::component::console::exception::invalid_argument_exception::InvalidArgumentException; use shirabe_external_packages::symfony::component::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::component::console::output::output_interface::OutputInterface; @@ -10,18 +11,22 @@ use shirabe_php_shim::{PhpMixed, UnexpectedValueException, array_map, strtolower use crate::advisory::auditor::Auditor; use crate::command::base_command::BaseCommand; use crate::command::completion_trait::CompletionTrait; +use crate::composer::Composer; use crate::config::json_config_source::JsonConfigSource; use crate::console::input::input_argument::InputArgument; use crate::console::input::input_option::InputOption; use crate::dependency_resolver::request::Request; use crate::factory::Factory; use crate::installer::Installer; +use crate::io::io_interface::IOInterface; use crate::json::json_file::JsonFile; use crate::package::base_package::BasePackage; #[derive(Debug)] pub struct RemoveCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl RemoveCommand { @@ -672,3 +677,29 @@ impl RemoveCommand { Ok(status) } } + +impl BaseCommand for RemoveCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/repository_command.rs b/crates/shirabe/src/command/repository_command.rs index cfe9065..86afe80 100644 --- a/crates/shirabe/src/command/repository_command.rs +++ b/crates/shirabe/src/command/repository_command.rs @@ -2,6 +2,7 @@ use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::completion::completion_input::CompletionInput; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; @@ -9,15 +10,26 @@ use shirabe_php_shim::{ InvalidArgumentException, PHP_URL_HOST, PhpMixed, RuntimeException, parse_url, strtolower, }; +use crate::command::base_command::BaseCommand; use crate::command::base_config_command::BaseConfigCommand; +use crate::composer::Composer; +use crate::config::Config; +use crate::config::json_config_source::JsonConfigSource; use crate::console::input::input_argument::InputArgument; use crate::console::input::input_option::InputOption; use crate::factory::Factory; +use crate::io::io_interface::IOInterface; use crate::json::json_file::JsonFile; #[derive(Debug)] pub struct RepositoryCommand { - inner: BaseConfigCommand, + inner: Command, + composer: Option, + io: Option>, + + config: Option, + config_file: Option, + config_source: Option, } impl RepositoryCommand { @@ -436,3 +448,81 @@ impl RepositoryCommand { }) } } + +impl BaseCommand for RepositoryCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> Option<&mut Composer> { + self.composer.as_mut() + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_ref() + } + + fn io_mut(&mut self) -> Option<&mut dyn IOInterface> { + self.io.as_mut() + } +} + +impl BaseCommand for RepositoryCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} + +impl BaseConfigCommand for RepositoryCommand { + fn config(&self) -> Option<&Config> { + self.config.as_ref() + } + + fn config_mut(&mut self) -> Option<&mut Config> { + self.config.as_mut() + } + + fn config_file(&self) -> Option<&JsonFile> { + self.config_file.as_ref() + } + + fn config_file_mut(&mut self) -> Option<&mut JsonFile> { + self.config_file.as_mut() + } + + fn config_source(&self) -> Option<&JsonConfigSource> { + self.config_source.as_ref() + } + + fn config_source_mut(&mut self) -> Option<&mut JsonConfigSource> { + self.config_source.as_mut() + } +} diff --git a/crates/shirabe/src/command/require_command.rs b/crates/shirabe/src/command/require_command.rs index 738790d..24dda7e 100644 --- a/crates/shirabe/src/command/require_command.rs +++ b/crates/shirabe/src/command/require_command.rs @@ -4,6 +4,7 @@ use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_external_packages::seld::signal::signal_handler::SignalHandler; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::component::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::component::console::output::output_interface::OutputInterface; use shirabe_php_shim::{ @@ -17,6 +18,7 @@ use crate::advisory::auditor::Auditor; use crate::command::base_command::BaseCommand; use crate::command::completion_trait::CompletionTrait; use crate::command::package_discovery_trait::PackageDiscoveryTrait; +use crate::composer::Composer; use crate::console::input::input_argument::InputArgument; use crate::console::input::input_option::InputOption; use crate::dependency_resolver::request::Request; @@ -45,7 +47,10 @@ use crate::util::silencer::Silencer; #[derive(Debug)] pub struct RequireCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, + newly_created: bool, first_require: bool, json: Option, @@ -1132,3 +1137,29 @@ impl RequireCommand { } } } + +impl BaseCommand for RequireCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/run_script_command.rs b/crates/shirabe/src/command/run_script_command.rs index 09624af..fac896a 100644 --- a/crates/shirabe/src/command/run_script_command.rs +++ b/crates/shirabe/src/command/run_script_command.rs @@ -1,13 +1,16 @@ //! ref: composer/src/Composer/Command/RunScriptCommand.php use anyhow::Result; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use shirabe_php_shim::{InvalidArgumentException, PhpMixed, RuntimeException}; use crate::command::base_command::BaseCommand; +use crate::composer::Composer; use crate::console::input::input_argument::InputArgument; use crate::console::input::input_option::InputOption; +use crate::io::io_interface::IOInterface; use crate::script::event::Event as ScriptEvent; use crate::script::script_events::ScriptEvents; use crate::util::platform::Platform; @@ -15,7 +18,10 @@ use crate::util::process_executor::ProcessExecutor; #[derive(Debug)] pub struct RunScriptCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, + script_events: Vec<&'static str>, } @@ -249,3 +255,29 @@ impl RunScriptCommand { Ok(result) } } + +impl BaseCommand for RunScriptCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/script_alias_command.rs b/crates/shirabe/src/command/script_alias_command.rs index c5bacc4..a02d646 100644 --- a/crates/shirabe/src/command/script_alias_command.rs +++ b/crates/shirabe/src/command/script_alias_command.rs @@ -1,17 +1,22 @@ //! ref: composer/src/Composer/Command/ScriptAliasCommand.php -use crate::command::base_command::BaseCommand; use crate::console::input::input_argument::InputArgument; use crate::console::input::input_option::InputOption; +use crate::io::io_interface::IOInterface; use crate::util::platform::Platform; +use crate::{command::base_command::BaseCommand, composer::Composer}; use anyhow::Result; use shirabe_external_packages::composer::pcre::preg::Preg; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use shirabe_php_shim::{InvalidArgumentException, LogicException, PhpMixed, is_string}; pub struct ScriptAliasCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, + script: String, description: String, aliases: Vec, @@ -125,3 +130,29 @@ impl ScriptAliasCommand { )?) } } + +impl BaseCommand for ScriptAliasCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/search_command.rs b/crates/shirabe/src/command/search_command.rs index 2e9de04..28f4fd1 100644 --- a/crates/shirabe/src/command/search_command.rs +++ b/crates/shirabe/src/command/search_command.rs @@ -1,16 +1,18 @@ //! ref: composer/src/Composer/Command/SearchCommand.php -use crate::command::base_command::BaseCommand; use crate::console::input::input_argument::InputArgument; use crate::console::input::input_option::InputOption; +use crate::io::io_interface::IOInterface; use crate::json::json_file::JsonFile; use crate::plugin::command_event::CommandEvent; use crate::plugin::plugin_events::PluginEvents; use crate::repository::composite_repository::CompositeRepository; use crate::repository::platform_repository::PlatformRepository; use crate::repository::repository_interface::RepositoryInterface; +use crate::{command::base_command::BaseCommand, composer::Composer}; use anyhow::Result; use indexmap::IndexMap; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::formatter::output_formatter::OutputFormatter; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; @@ -18,7 +20,9 @@ use shirabe_php_shim::{InvalidArgumentException, PhpMixed, implode, in_array, pr #[derive(Debug)] pub struct SearchCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl SearchCommand { @@ -177,3 +181,29 @@ impl SearchCommand { Ok(0) } } + +impl BaseCommand for SearchCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/self_update_command.rs b/crates/shirabe/src/command/self_update_command.rs index f69476d..b1b0c06 100644 --- a/crates/shirabe/src/command/self_update_command.rs +++ b/crates/shirabe/src/command/self_update_command.rs @@ -2,6 +2,7 @@ use anyhow::Result; use shirabe_external_packages::composer::pcre::preg::Preg; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::component::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::component::console::output::output_interface::OutputInterface; use shirabe_external_packages::symfony::component::finder::finder::Finder; @@ -32,7 +33,9 @@ use crate::util::platform::Platform; #[derive(Debug)] pub struct SelfUpdateCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl SelfUpdateCommand { @@ -1178,3 +1181,29 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\ result } } + +impl BaseCommand for SelfUpdateCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs index 8b5e967..52d2bd7 100644 --- a/crates/shirabe/src/command/show_command.rs +++ b/crates/shirabe/src/command/show_command.rs @@ -4,6 +4,7 @@ use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_external_packages::composer::semver::semver::Semver; use shirabe_external_packages::composer::spdx_licenses::spdx_licenses::SpdxLicenses; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::completion::completion_input::CompletionInput; use shirabe_external_packages::symfony::console::formatter::output_formatter::OutputFormatter; use shirabe_external_packages::symfony::console::formatter::output_formatter_style::OutputFormatterStyle; @@ -50,7 +51,10 @@ const _INPUT_OPTION_REF: i64 = InputOption::VALUE_NONE; #[derive(Debug)] pub struct ShowCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, + pub(crate) version_parser: VersionParser, pub(crate) colors: Vec, repository_set: Option, @@ -2640,6 +2644,32 @@ impl ShowCommand { impl CompletionTrait for ShowCommand {} +impl BaseCommand for ShowCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} + #[derive(Debug)] pub enum PackageOrName { Pkg(Box), diff --git a/crates/shirabe/src/command/status_command.rs b/crates/shirabe/src/command/status_command.rs index ff6675d..e4f25cd 100644 --- a/crates/shirabe/src/command/status_command.rs +++ b/crates/shirabe/src/command/status_command.rs @@ -2,11 +2,14 @@ use anyhow::Result; use indexmap::IndexMap; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use crate::command::base_command::BaseCommand; +use crate::composer::Composer; use crate::console::input::input_option::InputOption; +use crate::io::io_interface::IOInterface; use crate::package::dumper::array_dumper::ArrayDumper; use crate::package::version::version_guesser::VersionGuesser; use crate::package::version::version_parser::VersionParser; @@ -17,7 +20,9 @@ use crate::util::process_executor::ProcessExecutor; #[derive(Debug)] pub struct StatusCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl StatusCommand { @@ -301,3 +306,29 @@ impl StatusCommand { Ok(exit_code) } } + +impl BaseCommand for StatusCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/suggests_command.rs b/crates/shirabe/src/command/suggests_command.rs index efa0ce2..317b9c4 100644 --- a/crates/shirabe/src/command/suggests_command.rs +++ b/crates/shirabe/src/command/suggests_command.rs @@ -2,20 +2,27 @@ use crate::command::base_command::BaseCommand; use crate::command::completion_trait::CompletionTrait; +use crate::composer::Composer; use crate::console::input::input_argument::InputArgument; use crate::console::input::input_option::InputOption; use crate::installer::suggested_packages_reporter::SuggestedPackagesReporter; +use crate::io::io_interface::IOInterface; use crate::repository::installed_repository::InstalledRepository; use crate::repository::platform_repository::PlatformRepository; use crate::repository::root_package_repository::RootPackageRepository; use anyhow::Result; -use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; +use shirabe_external_packages::symfony::{ + component::console::command::command::Command, console::input::input_interface::InputInterface, +}; use shirabe_php_shim::{PhpMixed, empty, in_array}; #[derive(Debug)] pub struct SuggestsCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, + completion_trait: CompletionTrait, } @@ -112,3 +119,29 @@ impl SuggestsCommand { Ok(0) } } + +impl BaseCommand for SuggestsCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs index 0311cec..aeeb7ba 100644 --- a/crates/shirabe/src/command/update_command.rs +++ b/crates/shirabe/src/command/update_command.rs @@ -37,7 +37,9 @@ use crate::util::http_downloader::HttpDownloader; #[derive(Debug)] pub struct UpdateCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl CompletionTrait for UpdateCommand {} @@ -623,3 +625,29 @@ impl UpdateCommand { VersionSelector::new(repository_set) } } + +impl BaseCommand for UpdateCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} diff --git a/crates/shirabe/src/command/validate_command.rs b/crates/shirabe/src/command/validate_command.rs index e95e5ca..5906aaa 100644 --- a/crates/shirabe/src/command/validate_command.rs +++ b/crates/shirabe/src/command/validate_command.rs @@ -1,10 +1,12 @@ //! ref: composer/src/Composer/Command/ValidateCommand.php use anyhow::Result; +use shirabe_external_packages::symfony::component::console::command::command::Command; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use crate::command::base_command::BaseCommand; +use crate::composer::Composer; use crate::console::input::input_argument::InputArgument; use crate::console::input::input_option::InputOption; use crate::factory::Factory; @@ -17,7 +19,9 @@ use crate::util::filesystem::Filesystem; #[derive(Debug)] pub struct ValidateCommand { - inner: BaseCommand, + inner: Command, + composer: Option, + io: Option>, } impl ValidateCommand { @@ -330,3 +334,29 @@ impl ValidateCommand { } } } + +impl BaseCommand for ValidateCommand { + fn inner(&self) -> &Command { + &self.inner + } + + fn inner_mut(&mut self) -> &mut Command { + &mut self.inner + } + + fn composer(&self) -> Option<&Composer> { + self.composer.as_ref() + } + + fn composer_mut(&mut self) -> &mut Option { + &mut self.composer + } + + fn io(&self) -> Option<&dyn IOInterface> { + self.io.as_deref() + } + + fn io_mut(&mut self) -> &mut Option> { + &mut self.io + } +} -- cgit v1.3.1