Skip to content

Commit

Permalink
feat: Add support links
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed Apr 16, 2024
1 parent cc2d318 commit 1adeecd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ pub struct Metadata {
pub authors: Cow<'static, str>,
/// The URL of the crate's website
pub homepage: Cow<'static, str>,
/// The support information
pub supports: Cow<'static, str>,
}

/// Initialize [`Metadata`]
Expand All @@ -75,6 +77,7 @@ macro_rules! metadata {
name: env!("CARGO_PKG_NAME").into(),
authors: env!("CARGO_PKG_AUTHORS").replace(":", ", ").into(),
homepage: env!("CARGO_PKG_HOMEPAGE").into(),
supports: Default::default(),
}
}};
}
Expand All @@ -98,7 +101,8 @@ macro_rules! metadata {
/// name: env!("CARGO_PKG_NAME").into(),
/// version: env!("CARGO_PKG_VERSION").into(),
/// authors: "My Company Support <[email protected]>".into(),
/// homepage: "support.mycompany.com".into(),
/// homepage: "www.mycompany.com".into(),
/// supports: "- Open a support request by email to [email protected]".into(),
/// });
/// ```
#[macro_export]
Expand Down Expand Up @@ -180,8 +184,13 @@ fn write_msg<P: AsRef<Path>>(
file_path: Option<P>,
meta: &Metadata,
) -> IoResult<()> {
let (_version, name, authors, homepage) =
(&meta.version, &meta.name, &meta.authors, &meta.homepage);
let Metadata {
name,
authors,
homepage,
supports,
..
} = meta;

writeln!(buffer, "Well, this is embarrassing.\n")?;
writeln!(
Expand All @@ -207,6 +216,9 @@ fn write_msg<P: AsRef<Path>>(
if !authors.is_empty() {
writeln!(buffer, "- Authors: {authors}")?;
}
if !supports.is_empty() {
writeln!(buffer, "\nTo submit the crash report:\n\n{supports}")?;
}
writeln!(
buffer,
"\nWe take privacy seriously, and do not perform any \
Expand Down
1 change: 1 addition & 0 deletions tests/custom-panic/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ fn main() {
version: env!("CARGO_PKG_VERSION").into(),
authors: "My Company Support <[email protected]".into(),
homepage: "support.mycompany.com".into(),
supports: "- Open a support request by email to [email protected]".into()
});

println!("A normal log message");
Expand Down
4 changes: 4 additions & 0 deletions tests/custom-panic/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ We have generated a report file at \"[..].toml\". Submit an issue or email with
- Homepage: support.mycompany.com
- Authors: My Company Support <[email protected]
To submit the crash report:
- Open a support request by email to [email protected]
We take privacy seriously, and do not perform any automated error collection. In order to improve the software, we rely on people to submit reports.
Thank you kindly!
Expand Down

0 comments on commit 1adeecd

Please sign in to comment.