fd/src/app.rs

111 lines
3.7 KiB
Rust
Raw Normal View History

2017-10-04 14:31:08 +02:00
use clap::{App, AppSettings, Arg};
pub fn build_app() -> App<'static, 'static> {
App::new("fd")
2017-10-05 21:29:29 +02:00
.version(crate_version!())
.usage("fd [FLAGS/OPTIONS] [<pattern>] [<path>]")
.setting(AppSettings::ColoredHelp)
.setting(AppSettings::DeriveDisplayOrder)
.arg(
Arg::with_name("hidden")
2017-10-04 14:31:08 +02:00
.long("hidden")
.short("H")
2017-10-05 21:29:29 +02:00
.help("Search hidden files and directories"),
)
.arg(
Arg::with_name("no-ignore")
2017-10-04 14:31:08 +02:00
.long("no-ignore")
.short("I")
2017-10-05 21:29:29 +02:00
.help("Do not respect .(git)ignore files"),
)
.arg(
Arg::with_name("case-sensitive")
2017-10-04 14:31:08 +02:00
.long("case-sensitive")
.short("s")
2017-10-05 21:29:29 +02:00
.help("Case-sensitive search (default: smart case)"),
)
.arg(
Arg::with_name("absolute-path")
2017-10-04 14:31:08 +02:00
.long("absolute-path")
.short("a")
2017-10-05 21:29:29 +02:00
.help("Show absolute instead of relative paths"),
)
.arg(
Arg::with_name("follow")
2017-10-04 14:31:08 +02:00
.long("follow")
.short("L")
.alias("dereference")
2017-10-05 21:29:29 +02:00
.help("Follow symbolic links"),
)
.arg(
Arg::with_name("full-path")
2017-10-04 14:31:08 +02:00
.long("full-path")
.short("p")
2017-10-05 21:29:29 +02:00
.help("Search full path (default: file-/dirname only)"),
)
.arg(
Arg::with_name("null_separator")
2017-10-04 14:31:08 +02:00
.long("print0")
.short("0")
2017-10-05 21:29:29 +02:00
.help("Separate results by the null character"),
)
.arg(
Arg::with_name("depth")
2017-10-04 14:31:08 +02:00
.long("max-depth")
.short("d")
.takes_value(true)
2017-10-05 21:29:29 +02:00
.help("Set maximum search depth (default: none)"),
)
.arg(
Arg::with_name("file-type")
2017-10-04 14:31:08 +02:00
.long("type")
.short("t")
.takes_value(true)
2017-10-05 21:35:22 +02:00
.value_name("filetype")
2017-10-04 14:31:08 +02:00
.possible_values(&["f", "file", "d", "directory", "s", "symlink"])
.hide_possible_values(true)
2017-10-05 21:29:29 +02:00
.help("Filter by type: f(ile), d(irectory), s(ymlink)"),
)
.arg(
Arg::with_name("extension")
2017-10-04 14:31:08 +02:00
.long("extension")
.short("e")
.takes_value(true)
.value_name("ext")
2017-10-05 21:29:29 +02:00
.help("Filter by file extension"),
)
.arg(
Arg::with_name("color")
2017-10-04 14:31:08 +02:00
.long("color")
.short("c")
.takes_value(true)
2017-10-05 21:35:22 +02:00
.value_name("when")
2017-10-04 14:31:08 +02:00
.possible_values(&["never", "auto", "always"])
.hide_possible_values(true)
2017-10-05 21:29:29 +02:00
.help(
"When to use color in the output:\n\
never, auto, always (default: auto)",
),
)
.arg(
Arg::with_name("threads")
2017-10-04 14:31:08 +02:00
.long("threads")
.short("j")
.takes_value(true)
2017-10-05 21:35:22 +02:00
.value_name("num")
2017-10-05 21:29:29 +02:00
.help(
"Set number of threads to use for searching\n\
(default: number of available CPU cores)",
),
)
.arg(
Arg::with_name("max-buffer-time")
2017-10-04 14:31:08 +02:00
.long("max-buffer-time")
.takes_value(true)
.hidden(true)
2017-10-05 21:29:29 +02:00
.help("the time (in ms) to buffer, before streaming to the console"),
)
.arg(Arg::with_name("pattern").help("the search pattern, a regular expression (optional)"))
.arg(Arg::with_name("path").help("the root directory for the filesystem search (optional)"))
}