gt_tool/structs/
release.rs1use colored::Colorize;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Deserialize, Serialize)]
5pub struct Release {
6 pub id: usize,
7 pub tag_name: String,
8 target_commitish: String,
9 name: String,
10 body: String,
11 url: String,
12 html_url: String,
13 tarball_url: String,
14 zipball_url: String,
15 upload_url: String,
16 draft: bool,
17 prerelease: bool,
18 created_at: String,
19 published_at: String,
20 author: Author,
21}
22
23impl Release {
24 pub fn colorized(&self) -> String {
25 let tag = "Tag:".green().bold();
26 let name = "Name:".green();
27 let published = "Published:".bright_green();
28 let created = "Created:".green().dimmed();
29 let author = "Author:".blue();
30 let body = if !self.body.is_empty() {
31 &self.body.white()
32 } else {
33 &String::from("(empty body)").dimmed()
34 };
35
36 format!(
37 "{tag} {}
38{name} {}
39 {}
40{published} {} ({created} {})
41{author} {} ({})",
42 self.tag_name.bold(),
43 self.name,
44 body,
45 self.published_at,
46 self.created_at.dimmed(),
47 self.author.login,
48 self.author.email,
49 )
50 }
51}
52
53#[derive(Debug, Deserialize, Serialize)]
54pub struct Author {
55 id: usize,
56 login: String,
57 login_name: String,
58 source_id: usize,
59 full_name: String,
60 email: String,
61}
62
63#[derive(Debug, Serialize)]
64pub struct CreateReleaseOption {
65 pub body: String,
66 pub draft: bool,
67 pub name: String,
68 pub prerelease: bool,
69 pub tag_name: String,
70 pub target_commitish: String,
71}
72
73pub struct EditReleaseOption;