use anstyle;
use clap::{Args, Command, CommandFactory, Parser, Subcommand};
use clap_complete::{generate, Generator, Shell};
use std::{fmt::Debug, io};
mod center_opts;
mod clear_kinetics_opts;
mod ddda_to_m6a_opts;
mod decorator_opts;
mod extract_opts;
mod fire_opts;
mod footprint_opts;
mod nucleosome_opts;
mod pileup_opts;
mod predict_opts;
mod qc_opts;
mod strip_basemods_opts;
pub use center_opts::*;
pub use clear_kinetics_opts::*;
pub use ddda_to_m6a_opts::*;
pub use decorator_opts::*;
pub use extract_opts::*;
pub use fire_opts::*;
pub use footprint_opts::*;
pub use nucleosome_opts::*;
pub use pileup_opts::*;
pub use predict_opts::*;
pub use qc_opts::*;
pub use strip_basemods_opts::*;
#[derive(Parser)]
#[clap(
author,
version,
about,
propagate_version = true,
subcommand_required = true,
infer_subcommands = true,
arg_required_else_help = true
)]
#[command(version = super::LONG_VERSION)]
#[command(styles=get_styles())]
pub struct Cli {
#[clap(flatten)]
pub global: GlobalOpts,
#[clap(subcommand)]
pub command: Option<Commands>,
}
#[derive(Debug, Args, PartialEq, Eq)]
pub struct GlobalOpts {
#[clap(
global = true,
short,
long,
default_value_t = 8,
help_heading = "Global-Options"
)]
pub threads: usize,
#[clap(
global = true,
short,
long,
action = clap::ArgAction::Count,
help_heading = "Debug-Options"
)]
pub verbose: u8,
#[clap(global = true, long, help_heading = "Debug-Options")]
pub quiet: bool,
}
impl std::default::Default for GlobalOpts {
fn default() -> Self {
Self {
threads: 8,
verbose: 0,
quiet: false,
}
}
}
#[derive(Subcommand, Debug)]
pub enum Commands {
#[clap(visible_aliases = &["m6A", "m6a"])]
PredictM6A(PredictM6AOptions),
AddNucleosomes(AddNucleosomeOptions),
Fire(FireOptions),
#[clap(visible_aliases = &["ex", "e"])]
Extract(ExtractOptions),
#[clap(visible_aliases = &["c", "ct"])]
Center(CenterOptions),
Footprint(FootprintOptions),
Qc(QcOpts),
TrackDecorators(DecoratorOptions),
Pileup(PileupOptions),
ClearKinetics(ClearKineticsOptions),
StripBasemods(StripBasemodsOptions),
DddaToM6a(DddaToM6aOptions),
#[clap(hide = true)]
Completions(CompletionOptions),
#[clap(hide = true)]
Man {},
}
fn get_styles() -> clap::builder::Styles {
let cmd_color = anstyle::AnsiColor::Magenta;
let header_color = anstyle::AnsiColor::BrightGreen;
let placeholder_color = anstyle::AnsiColor::Cyan;
let header_style = anstyle::Style::new()
.bold()
.underline()
.fg_color(Some(anstyle::Color::Ansi(header_color)));
let cmd_style = anstyle::Style::new()
.bold()
.fg_color(Some(anstyle::Color::Ansi(cmd_color)));
let placeholder_style = anstyle::Style::new()
.fg_color(Some(anstyle::Color::Ansi(placeholder_color)));
clap::builder::Styles::styled()
.header(header_style)
.literal(cmd_style)
.usage(header_style)
.placeholder(placeholder_style)
}
pub fn print_completions<G: Generator>(gen: G, cmd: &mut Command) {
generate(gen, cmd, cmd.get_name().to_string(), &mut io::stdout());
}
pub fn make_cli_parse() -> Cli {
Cli::parse()
}
pub fn make_cli_app() -> Command {
Cli::command()
}
#[derive(Args, Debug, PartialEq, Eq)]
pub struct CompletionOptions {
#[arg(value_enum)]
pub shell: Shell,
}