This repository has no description
1use std::net::SocketAddr;
2use std::path::PathBuf;
3
4use clap::{Parser, Subcommand};
5
6mod diff;
7mod merge;
8mod protocol;
9mod service;
10
11#[derive(Parser)]
12#[command(name = "gitmirror", about = "Git mirror gRPC service")]
13struct Cli {
14 #[command(subcommand)]
15 cmd: Command,
16}
17
18#[derive(Subcommand)]
19enum Command {
20 /// Run the gRPC server.
21 Serve(ServeArgs),
22}
23
24#[derive(clap::Args)]
25struct ServeArgs {
26 /// Address to bind the gRPC server to.
27 #[arg(long, env = "GITMIRROR_ADDR", default_value = "127.0.0.1:9000")]
28 addr: SocketAddr,
29
30 /// Base directory holding bare mirror repos, one per DID (<base>/<did>).
31 #[arg(long, env = "GITMIRROR_REPO_BASE", default_value = "repos")]
32 repo_base: PathBuf,
33}
34
35#[tokio::main]
36async fn main() -> anyhow::Result<()> {
37 tracing_subscriber::fmt()
38 .with_env_filter(
39 tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| "info".into()),
40 )
41 .init();
42
43 match Cli::parse().cmd {
44 Command::Serve(args) => service::serve(args.addr, args.repo_base).await,
45 }
46}