use clap::Parser;
#[derive(Debug, Parser)]
#[allow(dead_code)]
#[clap(
version,
about = "Find and replace on grep output, or edit grep output to apply changes",
long_about = "Find and replace on grep output, or edit grep output to apply changes.\n\n\
rep takes grep-formatted lines (e.g., from ripgrep) and applies find and\n\
replace on the matches.\n\n\
EXAMPLES:\n \
grep -n foo * | rep foo bar Show diff replacing foo with bar\n \
grep -n foo * | rep foo bar -w Write the replacements to files\n\n\
EDITING STANDARD INPUT:\n \
Changes can also be made by editing the grep output directly, without\n \
passing find and replace arguments:\n \
1. grep -n foo * > tmp Save grep matches to a file\n \
2. Edit tmp in a text editor Make changes to the matched lines\n \
3. rep < tmp Preview the diff\n \
4. rep -w < tmp Write the changes\n \
Editing standard input and applying a find and replace can also be\n \
combined (e.g., rep bar baz < tmp).\n\n\
INPUT FORMAT:\n \
Each input line has the format: <file>:<line>:[<column>:]<text>\n \
The -n (--line-number) grep flag is required for correct line numbers.\n\n\
SPECIAL CHARACTERS:\n \
Use -- to separate options from arguments when the pattern starts\n \
with a hyphen (e.g., rep -- '--foo' '--bar').\n\n\
PAGER:\n \
The default pager is less. Set the REP_PAGER environment variable to\n \
override (e.g., export REP_PAGER=delta).",
disable_help_subcommand = true,
next_line_help = true,
)]
pub(crate) struct Options {
#[clap(short = 'w', long = "write")]
pub write: bool,
#[clap(short = 'd', long = "delete-lines")]
pub delete: bool,
#[clap(short = 's', long = "string-mode")]
pub literal_mode: bool,
#[clap(short = 'n')]
pub replacements: Option<usize>,
#[clap(long = "color")]
pub color: bool,
#[clap(long = "no-color")]
pub no_color: bool,
#[clap(long = "stdout")]
pub stdout: bool,
#[clap(short = 'f', long = "flags")]
pub flags: Option<String>,
pub find: Option<String>,
pub replace_with: Option<String>,
}