1 Commits

Author SHA1 Message Date
135acf09b7 Basic impl Display for the Release struct
I'm not certain what info I want to present when listing the Releases.

The idea is that the release version is the most important, and that it
matches the git-tag associated with the release. I'll print that first.

Next, the name of the release followed by the body text. The list of
releases will become quite large for some projects, and the body text
may include a changelog. Both of these will cause the output to become
quite large. I will need to create a size limiter, but I'm ignoring that
for now.

Who created the release and when may be useful when searching for a
release, so I've included that as the final section.
2025-07-02 12:56:17 -05:00
3 changed files with 28 additions and 16 deletions

View File

@@ -9,21 +9,6 @@ reqwest = { version = "0.11.13", features = ["json", "stream", "multipart"] }
serde = { version = "1.0.152", features = ["derive"] }
tokio = { version = "1.24.2", features = ["macros", "rt-multi-thread"] }
# Grand-dependency Pins ----
# Fixes: Reqwest uses too-old version of crate `log`
log = "0.4.6"
# Debian 12 uses OpenSSL 3.x and older libssl-sys crates are angry about that
# Fixes: native lib lookup.
# Causes: missing item in crate `ffi`
openssl-sys = "0.9.64"
# Fixes: missing item in crate `ffi` (from openssl-sys)
openssl = "0.10.35"
# End Grand-dependency Pins ----
# Packages available in Debian (Sid)
# clap = "4.5.23"
# reqwest = "0.12.15"

View File

@@ -34,7 +34,7 @@ async fn main() -> Result<(), gt_tool::Error> {
let releases =
gt_tool::api::release::list_releases(&client, &args.gitea_url, &args.repo).await?;
for release in releases {
println!("{:?}", release);
println!("{}", release);
}
}
gt_tool::cli::Commands::CreateRelease {

View File

@@ -1,3 +1,5 @@
use std::fmt::Display;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
@@ -19,6 +21,31 @@ pub struct Release {
author: Author,
}
impl Display for Release {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let body = if self.body.len() > 0 {
&self.body
} else {
&String::from("(empty body)")
};
write!(f,
"Tag: {}
Name: {}
{}
Published: {} (created: {})
Author: {} ({})
",
self.tag_name,
self.name,
body,
self.published_at,
self.created_at,
self.author.login,
self.author.email,
)
}
}
#[derive(Debug, Deserialize, Serialize)]
pub struct Author {
id: usize,