index : git-mirror-sync.git

ascending towards madness

use clap::Parser;
use tokio::time::sleep;

#[derive(Debug, Parser, Default)]
struct CliArgs {
    /// The time to wait before refreshing repositories.
    /// eg. 10m, 60s, etc.
    #[clap(short, long, default_value = "10m")]
    pub refresh_time: String,

    #[clap(required = true)]
    pub directory: String,
}

#[tokio::main]
async fn main() {
    loop {
        do_sync_task(CliArgs::parse()).await
    }
}

async fn do_sync_task(args: CliArgs) {
    // TODO: sync with git2
    println!("I am awake! {}", args.directory);

    sleep(
        args.refresh_time
            .parse::<humantime::Duration>()
            .expect("Unable to convert refresh_time")
            .into(),
    )
    .await;
}