use anyhow::Result;
use clap::Parser;
use std::sync::Arc;
use dkdc_rs::config::{config_it, init_config, load_config, print_config};
use dkdc_rs::open::open_things;
#[derive(Parser, Debug)]
#[command(name = "dkdc-rs")]
#[command(about = "bookmarks in your terminal")]
#[command(version)]
struct Args {
#[arg(short, long)]
config: bool,
#[arg(short, long, default_value = "1")]
max_workers: usize,
things: Vec<String>,
}
#[tokio::main]
async fn main() -> Result<()> {
let args = Args::parse();
init_config()?;
if args.config {
config_it()?;
return Ok(());
}
let config = Arc::new(load_config()?);
if args.things.is_empty() {
print_config(&config)?;
} else {
open_things(args.things, args.max_workers, config).await?;
}
Ok(())
}