mirror of
https://github.com/sharkdp/fd.git
synced 2024-09-28 13:01:30 +02:00
Update help message
This commit is contained in:
parent
3e5d9d81e7
commit
c5e796a225
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1,6 +1,6 @@
|
|||||||
[root]
|
[root]
|
||||||
name = "fd"
|
name = "fd"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "fd"
|
name = "fd"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
authors = ["David Peter <mail@david-peter.de>"]
|
authors = ["David Peter <mail@david-peter.de>"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
ansi_term = "0.9"
|
||||||
getopts = "0.2"
|
getopts = "0.2"
|
||||||
|
isatty = "0.1"
|
||||||
regex = "0.2"
|
regex = "0.2"
|
||||||
walkdir = "1"
|
walkdir = "1"
|
||||||
ansi_term = "0.9"
|
|
||||||
isatty = "0.1"
|
|
||||||
|
11
src/main.rs
11
src/main.rs
@ -26,6 +26,8 @@ struct FdOptions {
|
|||||||
max_depth: usize
|
max_depth: usize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MAX_DEPTH_DEFAULT : usize = 25;
|
||||||
|
|
||||||
/// Print a search result to the console.
|
/// Print a search result to the console.
|
||||||
fn print_entry(entry: &DirEntry, path_rel: &Path, config: &FdOptions) {
|
fn print_entry(entry: &DirEntry, path_rel: &Path, config: &FdOptions) {
|
||||||
let path_str = match path_rel.to_str() {
|
let path_str = match path_rel.to_str() {
|
||||||
@ -104,8 +106,9 @@ fn main() {
|
|||||||
opts.optflag("", "hidden",
|
opts.optflag("", "hidden",
|
||||||
"search hidden files/directories (default: off)");
|
"search hidden files/directories (default: off)");
|
||||||
opts.optflag("F", "follow", "follow symlinks (default: off)");
|
opts.optflag("F", "follow", "follow symlinks (default: off)");
|
||||||
opts.optflag("n", "no-color", "do not colorize output");
|
opts.optflag("n", "no-color", "do not colorize output (default: on)");
|
||||||
opts.optopt("d", "max-depth", "maximum search depth", "DEPTH");
|
opts.optopt("d", "max-depth",
|
||||||
|
"maximum search depth (default: 25)", "D");
|
||||||
|
|
||||||
let matches = match opts.parse(&args[1..]) {
|
let matches = match opts.parse(&args[1..]) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
@ -113,7 +116,7 @@ fn main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if matches.opt_present("h") {
|
if matches.opt_present("h") {
|
||||||
let brief = "Usage: fd [PATTERN]";
|
let brief = "Usage: fd [options] [PATTERN]";
|
||||||
print!("{}", opts.usage(&brief));
|
print!("{}", opts.usage(&brief));
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
@ -141,7 +144,7 @@ fn main() {
|
|||||||
max_depth:
|
max_depth:
|
||||||
matches.opt_str("max-depth")
|
matches.opt_str("max-depth")
|
||||||
.and_then(|ds| usize::from_str_radix(&ds, 10).ok())
|
.and_then(|ds| usize::from_str_radix(&ds, 10).ok())
|
||||||
.unwrap_or(25)
|
.unwrap_or(MAX_DEPTH_DEFAULT)
|
||||||
};
|
};
|
||||||
|
|
||||||
match RegexBuilder::new(pattern)
|
match RegexBuilder::new(pattern)
|
||||||
|
Loading…
Reference in New Issue
Block a user