gh_workflow_parser/gh/
gh_cli.rs1use super::{util, GitHub};
2
3#[derive(Debug, Default, Clone)]
4pub struct GitHubCli {
5 repo: String,
6}
7
8impl GitHubCli {
9 pub fn new(repo: String) -> Self {
10 Self { repo }
11 }
12}
13
14impl GitHub for GitHubCli {
15 fn run_summary(
16 &self,
17 repo: Option<&str>,
18 run_id: &str,
19 ) -> Result<String, Box<dyn std::error::Error>> {
20 let target_repo = repo.unwrap_or(&self.repo);
21 util::run_summary(target_repo, run_id)
22 }
23
24 fn failed_job_log(
25 &self,
26 repo: Option<&str>,
27 job_id: &str,
28 ) -> Result<String, Box<dyn std::error::Error>> {
29 let target_repo = repo.unwrap_or(&self.repo);
30 util::failed_job_log(target_repo, job_id)
31 }
32
33 fn create_issue(
34 &self,
35 repo: Option<&str>,
36 title: &str,
37 body: &str,
38 labels: &[String],
39 ) -> Result<(), Box<dyn std::error::Error>> {
40 let target_repo = repo.unwrap_or(&self.repo);
41 util::create_issue(target_repo, title, body, labels)
42 }
43
44 fn issue_bodies_open_with_label(
45 &self,
46 repo: Option<&str>,
47 label: &str,
48 ) -> Result<Vec<String>, Box<dyn std::error::Error>> {
49 let target_repo = repo.unwrap_or(&self.repo);
50 util::issue_bodies_open_with_label(target_repo, label)
51 }
52
53 fn all_labels(&self, repo: Option<&str>) -> Result<Vec<String>, Box<dyn std::error::Error>> {
54 let target_repo = repo.unwrap_or(&self.repo);
55 util::all_labels(target_repo)
56 }
57
58 fn create_label(
59 &self,
60 repo: Option<&str>,
61 name: &str,
62 color: &str,
63 description: &str,
64 force: bool,
65 ) -> Result<(), Box<dyn std::error::Error>> {
66 let target_repo = repo.unwrap_or(&self.repo);
67 util::create_label(target_repo, name, color, description, force)
68 }
69
70 fn default_repo(&self) -> &str {
71 &self.repo
72 }
73}