summaryrefslogtreecommitdiffstats
path: root/src/main.rs
blob: b2bc8443fcc07f81792db00ee82f0f0d00169d5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use anyhow::{Context, Result};
use clap::Parser;
use figment::providers::{Env, Format, Toml};
use projectr::{Cli, Config};
use tracing_subscriber::EnvFilter;

#[tracing::instrument]
fn main() -> Result<()> {
    let cli = Cli::parse();

    let config = Config::figment()
        .merge(&cli.projects)
        .merge(Toml::file("projectr.toml"))
        .merge(Env::prefixed("PROJECTR_"))
        .extract()
        .context("Failed to extract config")?;

    tracing_subscriber::fmt::fmt()
        .pretty()
        .with_writer(std::io::stderr)
        .with_max_level(cli.verbosity)
        .with_env_filter(EnvFilter::from_default_env())
        .init();

    projectr::run(&config).context("Failed to run projectr")
}