Release.colorized(), not std::fmt::Display

I don't know for sure if the string-ified version of a Release struct is
being printed to the terminal. As such, I don't know if the user wants,
does not want, or has mixed intentions for the stringification of this
thing.

No Display impl, instead just a `colorized()` method.
This commit is contained in:
2025-07-03 17:46:12 -05:00
parent d4ef21e243
commit f068e8233e
2 changed files with 4 additions and 5 deletions

View File

@@ -40,7 +40,7 @@ async fn main() -> Result<(), gt_tool::Error> {
releases releases
.iter() .iter()
.rev() .rev()
.map(|release| release.to_string()), .map(|release| release.colorized()),
String::from("") String::from("")
) )
.map(|release| println!("{}", release)) .map(|release| println!("{}", release))

View File

@@ -1,4 +1,3 @@
use std::fmt::Display;
use colored::Colorize; use colored::Colorize;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -22,8 +21,8 @@ pub struct Release {
author: Author, author: Author,
} }
impl Display for Release { impl Release {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { pub fn colorized(&self) -> String {
let tag = "Tag:".green().bold(); let tag = "Tag:".green().bold();
let name = "Name:".green(); let name = "Name:".green();
let published = "Published:".bright_green(); let published = "Published:".bright_green();
@@ -35,7 +34,7 @@ impl Display for Release {
&String::from("(empty body)").dimmed() &String::from("(empty body)").dimmed()
}; };
write!(f, format!(
"{tag} {} "{tag} {}
{name} {} {name} {}
{} {}