Skip to content

Commit

Permalink
Update help message
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed May 12, 2017
1 parent 3e5d9d8 commit c5e796a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "fd"
version = "0.1.0"
version = "0.2.0"
authors = ["David Peter <[email protected]>"]

[dependencies]
ansi_term = "0.9"
getopts = "0.2"
isatty = "0.1"
regex = "0.2"
walkdir = "1"
ansi_term = "0.9"
isatty = "0.1"
11 changes: 7 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -104,16 +106,17 @@ 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,
Err(e) => error(e.description())
};

if matches.opt_present("h") {
let brief = "Usage: fd [PATTERN]";
let brief = "Usage: fd [options] [PATTERN]";
print!("{}", opts.usage(&brief));
process::exit(1);
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c5e796a

Please sign in to comment.