summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 6d3fe4dcea7d3dbf358649ddd275af3f6442bbd2 (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
27
28
29
30
31
32
33
34
#![allow(clippy::multiple_crate_versions)]
use anyhow::Result;
use clap::Parser;
use reqwest::StatusCode;
use tracing::instrument;

mod cli;
mod command;
mod http;
mod nix;

use cli::Cli;
use command::Run;

#[derive(Clone, Debug, thiserror::Error)]
enum Error {
	#[error("Unstable to complete HTTP request: {0}")]
	HTTPFailed(StatusCode),
	#[error("Nix exited with code {code}: {stderr}")]
	Nix { code: i32, stderr: String },
}

#[tokio::main]
#[instrument]
async fn main() -> Result<()> {
	tracing_subscriber::fmt::init();

	let cli = Cli::parse();
	if let Err(why) = cli.run().await {
		eprintln!("{why}");
	}

	Ok(())
}