mod atproto;
mod constants;
mod env;
mod server;
mod templates;
mod xrpc;
use crate::{
constants::{COPYRIGHT_YEAR, PKG_AUTHORS, PKG_NAME},
env::Env,
};
use std::process::ExitCode;
#[macro_use]
extern crate rust_i18n;
i18n!("locales", fallback = "en");
#[rocket::main]
async fn main() -> ExitCode {
if let Some(arg) = std::env::args_os().nth(1)
&& arg == "license"
{
println!("{}", include_str!("../LICENSE"));
return ExitCode::SUCCESS;
}
let env = match Env::new() {
Ok(e) => e,
Err(err) => {
eprintln!("{err}");
return ExitCode::FAILURE;
}
};
println!(
"{} Copyright (C) {} {}
This program comes with ABSOLUTELY NO WARRANTY. This is
free software, and you are welcome to redistribute it
under certain conditions; type `{} license'
for details.",
PKG_NAME, COPYRIGHT_YEAR, PKG_AUTHORS, PKG_NAME,
);
let rocket = match server::http_service(env).ignite().await {
Ok(r) => r,
Err(err) => {
eprintln!("{err}");
return ExitCode::FAILURE;
}
};
if let Err(err) = rocket.launch().await {
eprintln!("{err}");
return ExitCode::FAILURE;
}
ExitCode::SUCCESS
}