2024-09-19 19:12:41 +01:00
|
|
|
//
|
|
|
|
use crate::model::Config;
|
2024-09-22 11:06:35 +01:00
|
|
|
use crate::patterns::issue_pattern;
|
2024-09-21 18:25:42 +01:00
|
|
|
use crate::printer::Printer;
|
2024-09-19 19:12:41 +01:00
|
|
|
use anyhow::{Context, Result};
|
2024-11-14 20:15:36 +00:00
|
|
|
use kxio::{fs::FileSystem, net::Net};
|
2024-09-19 19:12:41 +01:00
|
|
|
|
2024-11-14 20:15:36 +00:00
|
|
|
pub fn init_config<'net, 'fs>(
|
|
|
|
printer: &impl Printer,
|
|
|
|
fs: &'fs FileSystem,
|
|
|
|
net: &'net Net,
|
|
|
|
) -> Result<Config<'net, 'fs>> {
|
2024-09-19 19:12:41 +01:00
|
|
|
let config = Config::builder()
|
2024-09-20 07:23:36 +01:00
|
|
|
.net(net)
|
2024-11-14 20:15:36 +00:00
|
|
|
.fs(fs)
|
2024-09-19 19:12:41 +01:00
|
|
|
.repo(std::env::var("GITHUB_REPOSITORY").context("GITHUB_REPOSITORY")?)
|
|
|
|
.server(std::env::var("GITHUB_SERVER_URL").context("GITHUB_SERVER_URL")?)
|
|
|
|
.issue_pattern(issue_pattern()?)
|
|
|
|
.maybe_auth_token(std::env::var("REPO_TOKEN").ok())
|
|
|
|
.build();
|
|
|
|
|
2024-09-22 09:07:16 +01:00
|
|
|
printer.println("");
|
2024-09-22 11:06:35 +01:00
|
|
|
printer.println(format!("Repo : {}", config.repo()));
|
|
|
|
printer.println(format!("Regex: {}", config.issue_pattern()));
|
2024-09-22 09:07:16 +01:00
|
|
|
printer.println("");
|
2024-09-19 19:12:41 +01:00
|
|
|
|
|
|
|
Ok(config)
|
|
|
|
}
|