Skip to content
Myr

Add `search-path` option

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Multiple `--search-path` arguments can be supplied which replace the positional `path` argument for providing directories which will be searched. * When a `--search-path` argument is provided, positional `path` arguments will not be allowed

authored by Casey Primozic · committed by David Peter · parent e2bb932 · Browse files · 2 files+16 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+16 added−1 removed

  • other:+16 added−1 removed

2 files+16 added−1 removed

modified:src/app.rs+12 added
181 unmodified lines
182 .number_of_values(1),183 )184 .arg(arg("pattern"))185 .arg(arg("path").multiple(true))186 .arg(187 arg("search-path")188 .long("search-path")189 .takes_value(true)190 .conflicts_with("path")191 .multiple(true)192 .number_of_values(1),193 )194}195196#[cfg_attr(rustfmt, rustfmt_skip)]197fn usage() -> HashMap<&'static str, Help> {
123 unmodified lines
321 , "Limit results based on modification time within the duration provided or between date provided and now."322 , "Limit results based on modification time within the duration provided:\n \323 using a duration: <NUM>d <NUM>h <NUM>m <NUM>s (e.g. 10h, 1d, 35min...)\n \324 or a date and time: YYYY-MM-DD HH:MM:SS");325 doc!(h, "search-path"326 , "Provide paths to search as flag arguments rather than positional arguments."327 , "Provide paths to search as flag arguments, preventing the usage of any positional `path` arugments.\n\328 Changes the usage to `fd [FLAGS/OPTIONS] --search-path <path> --search-path <path2> [<pattern>]`");329 h330}
modified:src/main.rs+4 added-1 removed
60 unmodified lines
61 print_error_and_exit!("Error: could not get current directory.");62 }6364 // Get one or more root directories to search.65 let mut dir_vec: Vec<_> = match matches.values_of("path") {65 let mut dir_vec: Vec<_> = match matches66 .values_of("path")67 .or(matches.values_of("search-path"))68 {69 Some(paths) => paths70 .map(|path| {71 let path_buffer = PathBuf::from(path);72 if !fshelper::is_dir(&path_buffer) {
200 unmodified lines