mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-08-10 17:51:56 -07:00
cli: add --field-{context,match}-separator flags
These flags permit configuring the bytes used to delimit fields in match or context lines, where "fields" are things like the file path, line number, column number and the match/context itself. Fixes #1842, Closes #1871
This commit is contained in:
committed by
Andrew Gallant
parent
46d0130597
commit
578e1992fa
@@ -568,6 +568,8 @@ pub fn all_args_and_flags() -> Vec<RGArg> {
|
||||
flag_dfa_size_limit(&mut args);
|
||||
flag_encoding(&mut args);
|
||||
flag_engine(&mut args);
|
||||
flag_field_context_separator(&mut args);
|
||||
flag_field_match_separator(&mut args);
|
||||
flag_file(&mut args);
|
||||
flag_files(&mut args);
|
||||
flag_files_with_matches(&mut args);
|
||||
@@ -1231,6 +1233,38 @@ This overrides previous uses of --pcre2 and --auto-hybrid-regex flags.
|
||||
args.push(arg);
|
||||
}
|
||||
|
||||
fn flag_field_context_separator(args: &mut Vec<RGArg>) {
|
||||
const SHORT: &str = "Set the field context separator.";
|
||||
const LONG: &str = long!(
|
||||
"\
|
||||
Set the field context separator, which is used to delimit file paths, line
|
||||
numbers, columns and the context itself, when printing contextual lines. The
|
||||
separator may be any number of bytes, including zero. Escape sequences like
|
||||
\\x7F or \\t may be used. The default value is -.
|
||||
"
|
||||
);
|
||||
let arg = RGArg::flag("field-context-separator", "SEPARATOR")
|
||||
.help(SHORT)
|
||||
.long_help(LONG);
|
||||
args.push(arg);
|
||||
}
|
||||
|
||||
fn flag_field_match_separator(args: &mut Vec<RGArg>) {
|
||||
const SHORT: &str = "Set the match separator.";
|
||||
const LONG: &str = long!(
|
||||
"\
|
||||
Set the field match separator, which is used to delimit file paths, line
|
||||
numbers, columns and the match itself. The separator may be any number of
|
||||
bytes, including zero. Escape sequences like \\x7F or \\t may be used. The
|
||||
default value is -.
|
||||
"
|
||||
);
|
||||
let arg = RGArg::flag("field-match-separator", "SEPARATOR")
|
||||
.help(SHORT)
|
||||
.long_help(LONG);
|
||||
args.push(arg);
|
||||
}
|
||||
|
||||
fn flag_file(args: &mut Vec<RGArg>) {
|
||||
const SHORT: &str = "Search for patterns from the given file.";
|
||||
const LONG: &str = long!(
|
||||
|
Reference in New Issue
Block a user