Skip to content

Commit

Permalink
feat: ✨ Add Display trait for Metadata structure
Browse files Browse the repository at this point in the history
  • Loading branch information
AntwortEinesLebens committed Jan 17, 2025
1 parent 670f316 commit 919998f
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/commands/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,34 @@ struct Metadata {

impl Display for Metadata {
fn fmt(&self, formatter: &mut Formatter) -> FormatResult {
let mut authors_lines: String = String::default();

if let Some(authors) = &self.authors {
for (index, author) in authors.iter().enumerate() {
authors_lines.push_str(
format!(
"Author n°{}\n\
{}",
index + 1,
author
)
.as_str(),
);

if index != authors.len() - 1 {
authors_lines.push_str("\n\n");
}
}
}

write!(
formatter,
"Generation file metadata\n\
"Metadata\n\
Name: {}\n\
Version: {}\n\
References: {:?}",
self.name, self.version, self.references
References: {:#?}\n\n\
{}",
self.name, self.version, self.references, authors_lines
)
}
}
Expand Down

0 comments on commit 919998f

Please sign in to comment.