diff --git a/src/app.rs b/src/app.rs index 5e3cb06..be9967c 100644 --- a/src/app.rs +++ b/src/app.rs @@ -183,6 +183,14 @@ pub fn build_app() -> App<'static, 'static> { ) .arg(arg("pattern")) .arg(arg("path").multiple(true)) + .arg( + arg("search-path") + .long("search-path") + .takes_value(true) + .conflicts_with("path") + .multiple(true) + .number_of_values(1), + ) } #[cfg_attr(rustfmt, rustfmt_skip)] @@ -314,5 +322,9 @@ fn usage() -> HashMap<&'static str, Help> { , "Limit results based on modification time within the duration provided:\n \ using a duration: d h m s (e.g. 10h, 1d, 35min...)\n \ or a date and time: YYYY-MM-DD HH:MM:SS"); + doc!(h, "search-path" + , "Provide paths to search as flag arguments rather than positional arguments." + , "Provide paths to search as flag arguments, preventing the usage of any positional `path` arugments.\n\ + Changes the usage to `fd [FLAGS/OPTIONS] --search-path --search-path []`"); h } diff --git a/src/main.rs b/src/main.rs index dcb55a1..3807da6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,7 +62,10 @@ fn main() { } // Get one or more root directories to search. - let mut dir_vec: Vec<_> = match matches.values_of("path") { + let mut dir_vec: Vec<_> = match matches + .values_of("path") + .or(matches.values_of("search-path")) + { Some(paths) => paths .map(|path| { let path_buffer = PathBuf::from(path);