genome-sh 0.1.0

The jq of genomics. Fast, local, human-readable variant analysis.
use anyhow::Result;
use clap::{Args, Subcommand};

use crate::db::{self, DbTier};

#[derive(Args)]
pub struct DbArgs {
    #[command(subcommand)]
    command: DbCommand,
}

#[derive(Subcommand)]
enum DbCommand {
    /// Download and index a variant database.
    Install {
        /// Database tier: lite (ClinVar only), standard (+ gnomAD), full (+ dbSNP, PharmGKB).
        #[arg(default_value = "standard")]
        tier: DbTier,
    },

    /// Update databases to the latest release.
    Update,

    /// Show installed databases and versions.
    Status,

    /// Remove a specific database.
    Remove {
        /// Database to remove: clinvar, gnomad, dbsnp, pharmgkb, all.
        database: String,
    },
}

impl DbArgs {
    pub async fn run(self) -> Result<()> {
        match self.command {
            DbCommand::Install { tier } => db::install(tier).await,
            DbCommand::Update => db::update().await,
            DbCommand::Status => db::status(),
            DbCommand::Remove { database } => db::remove(&database),
        }
    }
}