1use anstyle;
2use clap::{Args, Command, CommandFactory, Parser, Subcommand};
3use clap_complete::{generate, Generator, Shell};
4use std::{fmt::Debug, io};
5
6mod center_opts;
8mod clear_kinetics_opts;
9mod ddda_to_m6a_opts;
10mod decorator_opts;
11mod extract_opts;
12mod fiber_hmm;
13mod fire_opts;
14mod footprint_opts;
15mod nucleosome_opts;
16mod pileup_opts;
17mod predict_opts;
18mod qc_opts;
19mod strip_basemods_opts;
20mod validate_opts;
21
22pub use center_opts::*;
24pub use clear_kinetics_opts::*;
25pub use ddda_to_m6a_opts::*;
26pub use decorator_opts::*;
27pub use extract_opts::*;
28pub use fiber_hmm::*;
29pub use fire_opts::*;
30pub use footprint_opts::*;
31pub use nucleosome_opts::*;
32pub use pileup_opts::*;
33pub use predict_opts::*;
34pub use qc_opts::*;
35pub use strip_basemods_opts::*;
36pub use validate_opts::ValidateOptions;
37
38#[derive(Parser)]
42#[clap(
43 author,
44 version,
45 about,
46 propagate_version = true,
47 subcommand_required = true,
48 infer_subcommands = true,
49 arg_required_else_help = true
50)]
51#[command(version = &**crate::FULL_VERSION)]
52#[command(styles=get_styles())]
53pub struct Cli {
54 #[clap(flatten)]
55 pub global: GlobalOpts,
56 #[clap(subcommand)]
58 pub command: Option<Commands>,
59}
60
61#[derive(Debug, Args, PartialEq, Eq)]
65pub struct GlobalOpts {
66 #[clap(
68 global = true,
69 short,
70 long,
71 default_value_t = 8,
72 help_heading = "Global-Options"
73 )]
74 pub threads: usize,
75
76 #[clap(
78 global = true,
79 short,
80 long,
81 action = clap::ArgAction::Count,
82 help_heading = "Debug-Options"
83 )]
84 pub verbose: u8,
85 #[clap(global = true, long, help_heading = "Debug-Options")]
87 pub quiet: bool,
88}
89
90impl std::default::Default for GlobalOpts {
91 fn default() -> Self {
92 Self {
93 threads: 8,
94 verbose: 0,
95 quiet: false,
96 }
97 }
98}
99
100#[derive(Subcommand, Debug)]
104pub enum Commands {
105 #[clap(visible_aliases = &["m6A", "m6a"])]
107 PredictM6A(PredictM6AOptions),
108 AddNucleosomes(AddNucleosomeOptions),
110 Fire(FireOptions),
112 #[clap(visible_aliases = &["ex", "e"])]
116 Extract(ExtractOptions),
117 #[clap(visible_aliases = &["c", "ct"])]
121 Center(CenterOptions),
122 Footprint(FootprintOptions),
124 Qc(QcOpts),
126 TrackDecorators(DecoratorOptions),
128 Pileup(PileupOptions),
130 ClearKinetics(ClearKineticsOptions),
132 StripBasemods(StripBasemodsOptions),
134 DddaToM6a(DddaToM6aOptions),
136 FiberHmm(FiberHmmOptions),
138 Validate(ValidateOptions),
140 #[clap(hide = true)]
142 Completions(CompletionOptions),
143 #[clap(hide = true)]
147 Man {},
148}
149
150fn get_styles() -> clap::builder::Styles {
156 let cmd_color = anstyle::AnsiColor::Magenta;
157 let header_color = anstyle::AnsiColor::BrightGreen;
158 let placeholder_color = anstyle::AnsiColor::Cyan;
159 let header_style = anstyle::Style::new()
160 .bold()
161 .underline()
162 .fg_color(Some(anstyle::Color::Ansi(header_color)));
163 let cmd_style = anstyle::Style::new()
164 .bold()
165 .fg_color(Some(anstyle::Color::Ansi(cmd_color)));
166 let placeholder_style = anstyle::Style::new()
167 .fg_color(Some(anstyle::Color::Ansi(placeholder_color)));
169 clap::builder::Styles::styled()
170 .header(header_style)
171 .literal(cmd_style)
172 .usage(header_style)
173 .placeholder(placeholder_style)
174}
175
176pub fn print_completions<G: Generator>(gen: G, cmd: &mut Command) {
177 generate(gen, cmd, cmd.get_name().to_string(), &mut io::stdout());
178}
179
180pub fn make_cli_parse() -> Cli {
181 Cli::parse()
182}
183
184pub fn make_cli_app() -> Command {
185 Cli::command()
186}
187
188#[derive(Args, Debug, PartialEq, Eq)]
189pub struct CompletionOptions {
190 #[arg(value_enum)]
192 pub shell: Shell,
193}