mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-17 09:28:25 +01:00
Rename option to strip_cwd_prefix, rename CLI option
This commit is contained in:
parent
359c0269ba
commit
4d7e34ad59
5 changed files with 13 additions and 13 deletions
|
@ -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. \
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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"))),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue