mirror of
https://github.com/sharkdp/fd
synced 2024-10-02 22:13:31 +00:00
Add case-sensitive flag, closes #9
This commit is contained in:
parent
2b9db47474
commit
23e51da3c9
|
@ -56,6 +56,7 @@ fn main() {
|
||||||
|
|
||||||
let mut opts = Options::new();
|
let mut opts = Options::new();
|
||||||
opts.optflag("h", "help", "print this help message");
|
opts.optflag("h", "help", "print this help message");
|
||||||
|
opts.optflag("s", "sensitive", "case-sensitive search");
|
||||||
let matches = match opts.parse(&args[1..]) {
|
let matches = match opts.parse(&args[1..]) {
|
||||||
Ok(m) => { m }
|
Ok(m) => { m }
|
||||||
Err(f) => { error(&f) }
|
Err(f) => { error(&f) }
|
||||||
|
@ -67,6 +68,8 @@ fn main() {
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let case_insensitive = !matches.opt_present("s");
|
||||||
|
|
||||||
let empty = String::new();
|
let empty = String::new();
|
||||||
let pattern = matches.free.get(0).unwrap_or(&empty);
|
let pattern = matches.free.get(0).unwrap_or(&empty);
|
||||||
|
|
||||||
|
@ -76,7 +79,7 @@ fn main() {
|
||||||
|
|
||||||
match
|
match
|
||||||
RegexBuilder::new(pattern)
|
RegexBuilder::new(pattern)
|
||||||
.case_insensitive(true)
|
.case_insensitive(case_insensitive)
|
||||||
.build() {
|
.build() {
|
||||||
Ok(re) =>
|
Ok(re) =>
|
||||||
scan(current_dir, &re),
|
scan(current_dir, &re),
|
||||||
|
|
Loading…
Reference in a new issue