From 919998f38d9cf2a6fc2cb9d073cefb99c04dcc8e Mon Sep 17 00:00:00 2001 From: AntwortEinesLebens Date: Fri, 17 Jan 2025 01:03:27 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Add=20Display=20trait=20for?= =?UTF-8?q?=20Metadata=20structure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/generate.rs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/commands/generate.rs b/src/commands/generate.rs index 50d80b2..baea79b 100644 --- a/src/commands/generate.rs +++ b/src/commands/generate.rs @@ -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 ) } }