Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c5e796a

Browse files
committed
Update help message
1 parent 3e5d9d8 commit c5e796a

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
22
name = "fd"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
authors = ["David Peter <[email protected]>"]
55

66
[dependencies]
7+
ansi_term = "0.9"
78
getopts = "0.2"
9+
isatty = "0.1"
810
regex = "0.2"
911
walkdir = "1"
10-
ansi_term = "0.9"
11-
isatty = "0.1"

src/main.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ struct FdOptions {
2626
max_depth: usize
2727
}
2828

29+
const MAX_DEPTH_DEFAULT : usize = 25;
30+
2931
/// Print a search result to the console.
3032
fn print_entry(entry: &DirEntry, path_rel: &Path, config: &FdOptions) {
3133
let path_str = match path_rel.to_str() {
@@ -104,16 +106,17 @@ fn main() {
104106
opts.optflag("", "hidden",
105107
"search hidden files/directories (default: off)");
106108
opts.optflag("F", "follow", "follow symlinks (default: off)");
107-
opts.optflag("n", "no-color", "do not colorize output");
108-
opts.optopt("d", "max-depth", "maximum search depth", "DEPTH");
109+
opts.optflag("n", "no-color", "do not colorize output (default: on)");
110+
opts.optopt("d", "max-depth",
111+
"maximum search depth (default: 25)", "D");
109112

110113
let matches = match opts.parse(&args[1..]) {
111114
Ok(m) => m,
112115
Err(e) => error(e.description())
113116
};
114117

115118
if matches.opt_present("h") {
116-
let brief = "Usage: fd [PATTERN]";
119+
let brief = "Usage: fd [options] [PATTERN]";
117120
print!("{}", opts.usage(&brief));
118121
process::exit(1);
119122
}
@@ -141,7 +144,7 @@ fn main() {
141144
max_depth:
142145
matches.opt_str("max-depth")
143146
.and_then(|ds| usize::from_str_radix(&ds, 10).ok())
144-
.unwrap_or(25)
147+
.unwrap_or(MAX_DEPTH_DEFAULT)
145148
};
146149

147150
match RegexBuilder::new(pattern)

0 commit comments

Comments
 (0)