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 #[arg(short = 'r', long)]
41 pub replacement: Option<String>,
42}
43
44impl Cli {
45 pub fn parse_engine(&self) -> crate::engine::EngineKind {
46 match self.engine.as_str() {
47 "fancy" => crate::engine::EngineKind::FancyRegex,
48 #[cfg(feature = "pcre2-engine")]
49 "pcre2" => crate::engine::EngineKind::Pcre2,
50 _ => crate::engine::EngineKind::RustRegex,
51 }
52 }
53}