From c5e796a225b7dc73678a8b981132fc3a8be97c13 Mon Sep 17 00:00:00 2001 From: sharkdp Date: Fri, 12 May 2017 23:37:09 +0200 Subject: Update help message --- Cargo.lock | 2 +- Cargo.toml | 6 +++--- src/main.rs | 11 +++++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9069a4f..fc86324 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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)", diff --git a/Cargo.toml b/Cargo.toml index 21a832b..94745e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "fd" -version = "0.1.0" +version = "0.2.0" authors = ["David Peter "] [dependencies] +ansi_term = "0.9" getopts = "0.2" +isatty = "0.1" regex = "0.2" walkdir = "1" -ansi_term = "0.9" -isatty = "0.1" diff --git a/src/main.rs b/src/main.rs index 48b0c2e..f2ca23e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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) -- cgit v1.2.3