forgejo-todo-checker/src/init.rs

29 lines
845 B
Rust
Raw Normal View History

2024-09-19 19:12:41 +01:00
//
use crate::model::Config;
use crate::patterns::issue_pattern;
use crate::printer::Printer;
2024-09-19 19:12:41 +01:00
use anyhow::{Context, Result};
use kxio::{fs::FileSystem, net::Net};
2024-09-19 19:12:41 +01: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)
.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("");
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)
}