1use clap::Parser;
2
3#[derive(Parser, Debug)]
4#[command(
5 name = "rgx",
6 version,
7 about = "regex101, but in your terminal",
8 long_about = "A terminal regex debugger with real-time matching, capture group highlighting, and plain-English explanations."
9)]
10pub struct Cli {
11 #[arg(value_name = "PATTERN")]
13 pub pattern: Option<String>,
14
15 #[arg(short, long, default_value = "rust")]
17 pub engine: String,
18
19 #[arg(short = 'i', long)]
21 pub case_insensitive: bool,
22
23 #[arg(short = 'm', long)]
25 pub multiline: bool,
26
27 #[arg(short = 's', long)]
29 pub dotall: bool,
30
31 #[arg(short = 'u', long)]
33 pub unicode: bool,
34
35 #[arg(short = 'x', long)]
37 pub extended: bool,
38}
39
40impl Cli {
41 pub fn parse_engine(&self) -> crate::engine::EngineKind {
42 match self.engine.as_str() {
43 "fancy" => crate::engine::EngineKind::FancyRegex,
44 #[cfg(feature = "pcre2-engine")]
45 "pcre2" => crate::engine::EngineKind::Pcre2,
46 _ => crate::engine::EngineKind::RustRegex,
47 }
48 }
49}