aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--crates/shirabe/src/dependency_resolver/operation/install_operation.rs10
-rw-r--r--crates/shirabe/src/dependency_resolver/operation/mark_alias_installed_operation.rs6
-rw-r--r--crates/shirabe/src/dependency_resolver/operation/mark_alias_uninstalled_operation.rs6
-rw-r--r--crates/shirabe/src/dependency_resolver/operation/operation_interface.rs4
-rw-r--r--crates/shirabe/src/dependency_resolver/operation/uninstall_operation.rs10
-rw-r--r--crates/shirabe/src/dependency_resolver/operation/update_operation.rs10
-rw-r--r--crates/shirabe/src/package/link.rs21
7 files changed, 39 insertions, 28 deletions
diff --git a/crates/shirabe/src/dependency_resolver/operation/install_operation.rs b/crates/shirabe/src/dependency_resolver/operation/install_operation.rs
index 1331591..ca3286c 100644
--- a/crates/shirabe/src/dependency_resolver/operation/install_operation.rs
+++ b/crates/shirabe/src/dependency_resolver/operation/install_operation.rs
@@ -45,11 +45,13 @@ impl OperationInterface for InstallOperation {
Self::format(self.package.clone(), lock)
}
- fn to_string(&self) -> String {
- self.show(true)
- }
-
fn as_install_operation(&self) -> Option<&InstallOperation> {
Some(self)
}
}
+
+impl std::fmt::Display for InstallOperation {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "{}", self.show(false))
+ }
+}
diff --git a/crates/shirabe/src/dependency_resolver/operation/mark_alias_installed_operation.rs b/crates/shirabe/src/dependency_resolver/operation/mark_alias_installed_operation.rs
index f5cb825..ab07b6a 100644
--- a/crates/shirabe/src/dependency_resolver/operation/mark_alias_installed_operation.rs
+++ b/crates/shirabe/src/dependency_resolver/operation/mark_alias_installed_operation.rs
@@ -44,8 +44,10 @@ impl OperationInterface for MarkAliasInstalledOperation {
.get_full_pretty_version(true, crate::package::DisplayMode::SourceRefIfDev),
)
}
+}
- fn to_string(&self) -> String {
- self.show(true)
+impl std::fmt::Display for MarkAliasInstalledOperation {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "{}", self.show(false))
}
}
diff --git a/crates/shirabe/src/dependency_resolver/operation/mark_alias_uninstalled_operation.rs b/crates/shirabe/src/dependency_resolver/operation/mark_alias_uninstalled_operation.rs
index f8314f5..1b107f0 100644
--- a/crates/shirabe/src/dependency_resolver/operation/mark_alias_uninstalled_operation.rs
+++ b/crates/shirabe/src/dependency_resolver/operation/mark_alias_uninstalled_operation.rs
@@ -44,8 +44,10 @@ impl OperationInterface for MarkAliasUninstalledOperation {
.get_full_pretty_version(true, crate::package::DisplayMode::SourceRefIfDev),
)
}
+}
- fn to_string(&self) -> String {
- self.show(true)
+impl std::fmt::Display for MarkAliasUninstalledOperation {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "{}", self.show(false))
}
}
diff --git a/crates/shirabe/src/dependency_resolver/operation/operation_interface.rs b/crates/shirabe/src/dependency_resolver/operation/operation_interface.rs
index 51b150c..30ed8eb 100644
--- a/crates/shirabe/src/dependency_resolver/operation/operation_interface.rs
+++ b/crates/shirabe/src/dependency_resolver/operation/operation_interface.rs
@@ -4,15 +4,13 @@ use crate::dependency_resolver::operation::InstallOperation;
use crate::dependency_resolver::operation::UninstallOperation;
use crate::dependency_resolver::operation::UpdateOperation;
-pub trait OperationInterface: std::fmt::Debug {
+pub trait OperationInterface: std::fmt::Display + std::fmt::Debug {
fn as_any(&self) -> &dyn std::any::Any;
fn get_operation_type(&self) -> String;
fn show(&self, lock: bool) -> String;
- fn to_string(&self) -> String;
-
fn as_install_operation(&self) -> Option<&InstallOperation> {
None
}
diff --git a/crates/shirabe/src/dependency_resolver/operation/uninstall_operation.rs b/crates/shirabe/src/dependency_resolver/operation/uninstall_operation.rs
index 465297d..efb3610 100644
--- a/crates/shirabe/src/dependency_resolver/operation/uninstall_operation.rs
+++ b/crates/shirabe/src/dependency_resolver/operation/uninstall_operation.rs
@@ -44,11 +44,13 @@ impl OperationInterface for UninstallOperation {
Self::format(self.package.clone(), lock)
}
- fn to_string(&self) -> String {
- self.show(true)
- }
-
fn as_uninstall_operation(&self) -> Option<&UninstallOperation> {
Some(self)
}
}
+
+impl std::fmt::Display for UninstallOperation {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "{}", self.show(false))
+ }
+}
diff --git a/crates/shirabe/src/dependency_resolver/operation/update_operation.rs b/crates/shirabe/src/dependency_resolver/operation/update_operation.rs
index 0bf3e35..76b1718 100644
--- a/crates/shirabe/src/dependency_resolver/operation/update_operation.rs
+++ b/crates/shirabe/src/dependency_resolver/operation/update_operation.rs
@@ -95,11 +95,13 @@ impl OperationInterface for UpdateOperation {
)
}
- fn to_string(&self) -> String {
- self.show(true)
- }
-
fn as_update_operation(&self) -> Option<&UpdateOperation> {
Some(self)
}
}
+
+impl std::fmt::Display for UpdateOperation {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "{}", self.show(false))
+ }
+}
diff --git a/crates/shirabe/src/package/link.rs b/crates/shirabe/src/package/link.rs
index 946c664..0157989 100644
--- a/crates/shirabe/src/package/link.rs
+++ b/crates/shirabe/src/package/link.rs
@@ -76,23 +76,26 @@ impl Link {
&self.pretty_constraint
}
- pub fn to_string(&self) -> String {
+ pub fn get_pretty_string(&self, source_package: PackageInterfaceHandle) -> String {
format!(
- "{} {} {} ({})",
- self.source,
+ "{} {} {} {}",
+ source_package.get_pretty_string(),
self.description,
self.target,
- self.constraint.to_string(),
+ self.constraint.get_pretty_string()
)
}
+}
- pub fn get_pretty_string(&self, source_package: PackageInterfaceHandle) -> String {
- format!(
- "{} {} {} {}",
- source_package.get_pretty_string(),
+impl std::fmt::Display for Link {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(
+ f,
+ "{} {} {} ({})",
+ self.source,
self.description,
self.target,
- self.constraint.get_pretty_string()
+ self.constraint.to_string(),
)
}
}