Add basic gitignore functionality

No support for wildcards and exact matches might screw up nested
directories. The Globbing functionality seems like its going to be a
pain to properly match up.
This commit is contained in:
Cameron Cordes
2020-05-20 15:38:26 -04:00
parent ee3e61b76d
commit 1229c05d8d
4 changed files with 60 additions and 9 deletions

View File

@@ -6,6 +6,7 @@ pub struct Config {
pub pattern: String,
pub ignore_case: bool,
pub path: String,
pub use_gitignore: bool,
}
impl Config {
@@ -28,7 +29,12 @@ impl Config {
Arg::with_name("path")
.help("Path to search in")
.index(2)
.default_value("."),
.default_value(""),
)
.arg(
Arg::with_name("gitignore")
.long("no-gitignore")
.help("Include results that are specified in .gitignore"),
)
.get_matches();
@@ -36,6 +42,7 @@ impl Config {
pattern: String::from(matches.value_of("pattern").unwrap()),
ignore_case: matches.is_present("ignore case"),
path: String::from(matches.value_of("path").unwrap()),
use_gitignore: !matches.is_present("gitignore"),
}
}
}