Update help message

This commit is contained in:
sharkdp 2017-05-12 23:37:09 +02:00
parent 9db4722010
commit 9aa4f0a124
3 changed files with 11 additions and 8 deletions

2
Cargo.lock generated
View File

@ -1,6 +1,6 @@
[root]
name = "fd"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"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)",

View File

@ -1,11 +1,11 @@
[package]
name = "fd"
version = "0.1.0"
version = "0.2.0"
authors = ["David Peter <mail@david-peter.de>"]
[dependencies]
ansi_term = "0.9"
getopts = "0.2"
isatty = "0.1"
regex = "0.2"
walkdir = "1"
ansi_term = "0.9"
isatty = "0.1"

View File

@ -26,6 +26,8 @@ struct FdOptions {
max_depth: usize
}
const MAX_DEPTH_DEFAULT : usize = 25;
/// Print a search result to the console.
fn print_entry(entry: &DirEntry, path_rel: &Path, config: &FdOptions) {
let path_str = match path_rel.to_str() {
@ -104,8 +106,9 @@ fn main() {
opts.optflag("", "hidden",
"search hidden files/directories (default: off)");
opts.optflag("F", "follow", "follow symlinks (default: off)");
opts.optflag("n", "no-color", "do not colorize output");
opts.optopt("d", "max-depth", "maximum search depth", "DEPTH");
opts.optflag("n", "no-color", "do not colorize output (default: on)");
opts.optopt("d", "max-depth",
"maximum search depth (default: 25)", "D");
let matches = match opts.parse(&args[1..]) {
Ok(m) => m,
@ -113,7 +116,7 @@ fn main() {
};
if matches.opt_present("h") {
let brief = "Usage: fd [PATTERN]";
let brief = "Usage: fd [options] [PATTERN]";
print!("{}", opts.usage(&brief));
process::exit(1);
}
@ -141,7 +144,7 @@ fn main() {
max_depth:
matches.opt_str("max-depth")
.and_then(|ds| usize::from_str_radix(&ds, 10).ok())
.unwrap_or(25)
.unwrap_or(MAX_DEPTH_DEFAULT)
};
match RegexBuilder::new(pattern)