mfs 0.2.1

Fetcher for scholarly metadata
use clap::{CommandFactory, Parser, Subcommand};
use std::path::PathBuf;

use crate::{
    output::MetadataSource, publications::handle_pub_command, server::handle_server_command,
};

pub async fn run() {
    let args = Args::parse();

    match &args.command {
        Some(Commands::Pub {
            command: Some(command),
        }) => {
            handle_pub_command(command).await;
        }
        // Some(Commands::Server { port }) => {
        //     handle_server_command(port).await;
        // }
        _ => {
            let mut cmd = Args::command();
            let _ = cmd.print_help();
        }
    }
}

#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
pub struct Args {
    #[command(subcommand)]
    pub command: Option<Commands>,
}

#[derive(Subcommand, Debug)]
pub enum Commands {
    #[command(about = "Get publication metadata")]
    Pub {
        #[command(subcommand)]
        command: Option<PubCommands>,
    },
    // Server {
    //     #[arg(short, long, help = "Port")]
    //     port: Option<u16>,
    // },
}

#[derive(Subcommand, Debug)]
pub enum PubCommands {
    #[command(about = "Fetch metadata via DOI")]
    Doi {
        doi: Option<String>,
        #[arg(value_enum, short, long, help = "Specifies source for the metadata, can be used multiple times to specify fallbacks", ignore_case = true, default_values_t = vec![MetadataSource::Crossref])]
        source_list: Vec<MetadataSource>,
        #[arg(short, long, help = "Path for the output")]
        output_path: Option<PathBuf>,
    },
}