mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-17 17:35:16 +01:00
Add search-path
option
* 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
This commit is contained in:
parent
e2bb932f87
commit
cdf737bf5c
2 changed files with 16 additions and 1 deletions
12
src/app.rs
12
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: <NUM>d <NUM>h <NUM>m <NUM>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 <path> --search-path <path2> [<pattern>]`");
|
||||
h
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue