Rename option to strip_cwd_prefix, rename CLI option

This commit is contained in:
David Peter 2021-11-26 17:46:04 +01:00
parent 359c0269ba
commit 4d7e34ad59
5 changed files with 13 additions and 13 deletions

View file

@ -617,10 +617,10 @@ pub fn build_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name("strip-prefix")
.long("strip-prefix")
.short("P")
Arg::with_name("strip-cwd-prefix")
.long("strip-cwd-prefix")
.conflicts_with_all(&["path", "search-path"])
.hidden_short_help(true)
.help("When no search path is provided and output is non-tty, strip './' prefix from results")
.long_help(
"By default, relative results are prefixed with './' when output to non-ttys. \

View file

@ -110,6 +110,6 @@ pub struct Config {
/// The maximum number of search results
pub max_results: Option<usize>,
/// Whether to prefix each relative path with "./"
pub no_strip: bool,
/// Whether or not to strip the './' prefix for search results
pub strip_cwd_prefix: bool,
}

View file

@ -375,9 +375,9 @@ fn construct_config(matches: clap::ArgMatches, pattern_regex: &str) -> Result<Co
None
}
}),
no_strip: matches.is_present("path")
|| matches.is_present("search-path")
|| (!interactive_terminal && !matches.is_present("strip-prefix")),
strip_cwd_prefix: (!matches.is_present("path")
&& !matches.is_present("search-path")
&& (interactive_terminal || matches.is_present("strip-cwd-prefix"))),
})
}

View file

@ -22,10 +22,10 @@ pub fn print_entry(
config: &Config,
wants_to_quit: &Arc<AtomicBool>,
) {
let path = if config.no_strip {
entry
} else {
let path = if config.strip_cwd_prefix {
strip_current_dir(entry)
} else {
entry
};
let r = if let Some(ref ls_colors) = config.ls_colors {

View file

@ -1925,11 +1925,11 @@ fn test_error_if_hidden_not_set_and_pattern_starts_with_dot() {
}
#[test]
fn test_no_strip() {
fn test_strip_cwd_prefix() {
let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);
te.assert_output(
&["-P", "."],
&["--strip-cwd-prefix", "."],
"a.foo
e1 e2
one