forked from
microcosm.blue/microcosm-rs
Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm
1use clap::Parser;
2use pocket::{Storage, serve};
3use std::path::PathBuf;
4
5/// Slingshot record edge cache
6#[derive(Parser, Debug, Clone)]
7#[command(version, about, long_about = None)]
8struct Args {
9 /// path to the sqlite db file
10 #[arg(long)]
11 db: Option<PathBuf>,
12 /// just initialize the db and exit
13 #[arg(long, action)]
14 init_db: bool,
15 /// the domain for serving a did doc (unused if running behind reflector)
16 #[arg(long)]
17 domain: Option<String>,
18}
19
20#[tokio::main]
21async fn main() {
22 tracing_subscriber::fmt::init();
23 log::info!("👖 hi");
24 let args = Args::parse();
25 let domain = args.domain.unwrap_or("bad-example.com".into());
26 let db_path = args.db.unwrap_or("prefs.sqlite3".into());
27 if args.init_db {
28 Storage::init(&db_path).unwrap();
29 log::info!("👖 initialized db at {db_path:?}. bye")
30 } else {
31 let storage = Storage::connect(db_path).unwrap();
32 serve(&domain, storage).await
33 }
34}