1use anyhow::{Context, Result};
2use clap::Parser;
3use oauth2::basic::BasicClient;
4
5pub fn init_logging() {
6 tracing_subscriber::fmt::init();
7 tracing::debug!("Initialised logging");
8}
9
10#[derive(Parser)]
11pub struct Args {
12 #[arg(long)]
13 pub bind: std::net::SocketAddr,
14}
15
16pub fn parse_args() -> Args {
17 Args::parse()
18}
19
20pub struct State {
21 pub oauth2_client: BasicClient,
22}
23
24pub fn github_credentials_from_env() -> Result<(String, String)> {
25 Ok((
26 std::env::var("GITHUB_CLIENT_ID").context("github client id")?,
27 std::env::var("GITHUB_CLIENT_SECRET").context("github client secret")?,
28 ))
29}
30
31pub fn error_report(result: Result<()>) {
32 if let Err(error) = result {
33 tracing::error!("Runtime error:");
34 for error in error.chain() {
35 tracing::error!("--> {}", error);
36 }
37 }
38}