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:
@@ -40,7 +40,7 @@ async fn main() -> Result<(), gt_tool::Error> {
|
||||
releases
|
||||
.iter()
|
||||
.rev()
|
||||
.map(|release| release.to_string()),
|
||||
.map(|release| release.colorized()),
|
||||
String::from("")
|
||||
)
|
||||
.map(|release| println!("{}", release))
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use colored::Colorize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -22,8 +21,8 @@ pub struct Release {
|
||||
author: Author,
|
||||
}
|
||||
|
||||
impl Display for Release {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
impl Release {
|
||||
pub fn colorized(&self) -> String {
|
||||
let tag = "Tag:".green().bold();
|
||||
let name = "Name:".green();
|
||||
let published = "Published:".bright_green();
|
||||
@@ -35,7 +34,7 @@ impl Display for Release {
|
||||
&String::from("(empty body)").dimmed()
|
||||
};
|
||||
|
||||
write!(f,
|
||||
format!(
|
||||
"{tag} {}
|
||||
{name} {}
|
||||
{}
|
||||
|
||||
Reference in New Issue
Block a user