diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-12 04:05:24 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-12 04:05:24 +0900 |
| commit | 3e2f7d6803cade819f960b71106338860194fcf1 (patch) | |
| tree | bc5e326e644d246cd71541f6337401fbace07992 /crates/shirabe/src/dependency_resolver | |
| parent | 35a96b4fbf25c6463c00f31f1a295e77f6fcb5d4 (diff) | |
| download | php-shirabe-3e2f7d6803cade819f960b71106338860194fcf1.tar.gz php-shirabe-3e2f7d6803cade819f960b71106338860194fcf1.tar.zst php-shirabe-3e2f7d6803cade819f960b71106338860194fcf1.zip | |
feat(port): port UninstallOperation.php
Diffstat (limited to 'crates/shirabe/src/dependency_resolver')
| -rw-r--r-- | crates/shirabe/src/dependency_resolver/operation/uninstall_operation.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/crates/shirabe/src/dependency_resolver/operation/uninstall_operation.rs b/crates/shirabe/src/dependency_resolver/operation/uninstall_operation.rs index 19b910e..b0b6fee 100644 --- a/crates/shirabe/src/dependency_resolver/operation/uninstall_operation.rs +++ b/crates/shirabe/src/dependency_resolver/operation/uninstall_operation.rs @@ -1 +1,46 @@ //! ref: composer/src/Composer/DependencyResolver/Operation/UninstallOperation.php + +use crate::dependency_resolver::operation::operation_interface::OperationInterface; +use crate::dependency_resolver::operation::solver_operation::SolverOperation; +use crate::package::package_interface::PackageInterface; + +#[derive(Debug)] +pub struct UninstallOperation { + pub(crate) package: Box<dyn PackageInterface>, +} + +impl UninstallOperation { + pub fn new(package: Box<dyn PackageInterface>) -> Self { + Self { package } + } + + pub fn get_package(&self) -> &dyn PackageInterface { + self.package.as_ref() + } + + pub fn format(package: &dyn PackageInterface, _lock: bool) -> String { + format!( + "Removing <info>{}</info> (<comment>{}</comment>)", + package.get_pretty_name(), + package.get_full_pretty_version(), + ) + } +} + +impl SolverOperation for UninstallOperation { + const TYPE: &'static str = "uninstall"; +} + +impl OperationInterface for UninstallOperation { + fn get_operation_type(&self) -> String { + Self::TYPE.to_string() + } + + fn show(&self, lock: bool) -> String { + Self::format(self.package.as_ref(), lock) + } + + fn to_string(&self) -> String { + self.show(true) + } +} |
