use anyhow::Result;
use clap::{Parser, Subcommand};
use crate::modules;
#[derive(Parser, Debug)]
#[command(
name = "biolic",
version,
author,
about = "A modular bioinformatics toolkit in Rust",
long_about = "biolic is a modular, fast, memory-efficient toolkit for processing \
sequencing data, with first-class support for long reads (PacBio HiFi \
and Oxford Nanopore) and unaligned BAM input. Streaming-first design \
guarantees constant memory regardless of input file size."
)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
#[arg(long, global = true)]
pub no_log: bool,
#[arg(short, long, global = true)]
pub quiet: bool,
#[arg(short, long, global = true)]
pub verbose: bool,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
Stats(modules::stats::StatsArgs),
Count(modules::count::CountArgs),
Filter(modules::filter::FilterArgs),
Convert(modules::convert::ConvertArgs),
Sample(modules::sample::SampleArgs),
Grep(modules::grep::GrepArgs),
Head(modules::head::HeadArgs),
Tail(modules::tail::TailArgs),
Qc(modules::qc::QcArgs),
Logs(modules::logs::LogsArgs),
}
pub fn run(cli: Cli) -> Result<()> {
let context = RunContext {
no_log: cli.no_log,
quiet: cli.quiet,
verbose: cli.verbose,
};
match cli.command {
Commands::Stats(args) => modules::stats::run(args, &context),
Commands::Count(args) => modules::count::run(args, &context),
Commands::Filter(args) => modules::filter::run(args, &context),
Commands::Convert(args) => modules::convert::run(args, &context),
Commands::Sample(args) => modules::sample::run(args, &context),
Commands::Grep(args) => modules::grep::run(args, &context),
Commands::Head(args) => modules::head::run(args, &context),
Commands::Tail(args) => modules::tail::run(args, &context),
Commands::Qc(args) => modules::qc::run(args, &context),
Commands::Logs(args) => modules::logs::run(args, &context),
}
}
#[derive(Debug, Clone)]
pub struct RunContext {
pub no_log: bool,
pub quiet: bool,
pub verbose: bool,
}