Skip to main content

rgx/config/
cli.rs

1use clap::Parser;
2
3#[derive(Parser, Debug)]
4#[command(
5    name = "rgx",
6    version,
7    about = "Terminal regex tester with real-time matching and multi-engine support",
8    long_about = "Test and debug regular expressions without leaving your terminal. Supports 3 engines (Rust regex, fancy-regex, PCRE2), capture group highlighting, plain-English explanations, and replace mode. Useful for remote work, shell pipelines, and engine-specific testing."
9)]
10pub struct Cli {
11    /// Initial regex pattern
12    #[arg(value_name = "PATTERN")]
13    pub pattern: Option<String>,
14
15    /// Engine to use: rust, fancy, or pcre2
16    #[arg(short, long)]
17    pub engine: Option<String>,
18
19    /// Case-insensitive matching
20    #[arg(short = 'i', long)]
21    pub case_insensitive: bool,
22
23    /// Multi-line mode
24    #[arg(short = 'm', long)]
25    pub multiline: bool,
26
27    /// Dot matches newline
28    #[arg(short = 's', long)]
29    pub dotall: bool,
30
31    /// Unicode mode
32    #[arg(short = 'u', long)]
33    pub unicode: Option<bool>,
34
35    /// Extended mode (ignore whitespace)
36    #[arg(short = 'x', long)]
37    pub extended: bool,
38
39    /// Initial replacement string
40    #[arg(short = 'r', long)]
41    pub replacement: Option<String>,
42
43    /// Read test string from file
44    #[arg(short = 'f', long)]
45    pub file: Option<String>,
46
47    /// Test string (alternative to stdin or file)
48    #[arg(short = 't', long)]
49    pub text: Option<String>,
50
51    /// Load workspace from file
52    #[arg(short = 'l', long)]
53    pub load: Option<String>,
54
55    /// Print matches to stdout and exit (non-interactive batch mode).
56    /// Requires a pattern and input (stdin, --file, or --text).
57    #[arg(short = 'p', long)]
58    pub print: bool,
59
60    /// After interactive session, print the final pattern to stdout instead of matches.
61    /// Useful for: eval $(rgx -P)
62    #[arg(short = 'P', long, conflicts_with = "print")]
63    pub output_pattern: bool,
64
65    /// Print a specific capture group instead of the full match (use with --print).
66    /// Accepts a group number (1, 2, ...) or a named group.
67    #[arg(short = 'g', long, requires = "print", conflicts_with = "count")]
68    pub group: Option<String>,
69
70    /// Print only the count of matches (use with --print).
71    #[arg(short = 'c', long, requires = "print", conflicts_with = "group")]
72    pub count: bool,
73
74    /// Use rounded border characters for panels.
75    #[arg(long)]
76    pub rounded: bool,
77
78    /// Enable vim-style modal keybindings (Normal/Insert mode).
79    #[arg(long)]
80    pub vim: bool,
81}