From 34e1a3d2902df194826984d2531233197336b417 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 26 Dec 2025 10:34:37 -0600 Subject: [PATCH] feat: Report repository as fallback from homepage Fixes #77 Closes #78 --- src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index a6d09f9..0b518ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -64,6 +64,7 @@ pub struct Metadata { version: Cow<'static, str>, authors: Option>, homepage: Option>, + repository: Option>, support: Option>, } @@ -75,6 +76,7 @@ impl Metadata { version: version.into(), authors: None, homepage: None, + repository: None, support: None, } } @@ -97,6 +99,15 @@ impl Metadata { self } + /// The URL of the crate's repository + pub fn repository(mut self, value: impl Into>) -> Self { + let value = value.into(); + if !value.is_empty() { + self.repository = value.into(); + } + self + } + /// The support information pub fn support(mut self, value: impl Into>) -> Self { let value = value.into(); @@ -114,6 +125,7 @@ macro_rules! metadata { $crate::Metadata::new(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")) .authors(env!("CARGO_PKG_AUTHORS").replace(":", ", ")) .homepage(env!("CARGO_PKG_HOMEPAGE")) + .repository(env!("CARGO_PKG_REPOSITORY")) }}; } @@ -228,6 +240,7 @@ fn write_msg>( name, authors, homepage, + repository, support, .. } = meta; @@ -252,6 +265,8 @@ fn write_msg>( if let Some(homepage) = homepage { writeln!(buffer, "- Homepage: {homepage}")?; + } else if let Some(repository) = repository { + writeln!(buffer, "- Repository: {repository}")?; } if let Some(authors) = authors { writeln!(buffer, "- Authors: {authors}")?;