mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-22 09:01:04 -05:00
feat: Ignore parents flag
This commit is contained in:
parent
1bd4ca8288
commit
6bbf8390ff
1 changed files with 22 additions and 1 deletions
23
src/main.rs
23
src/main.rs
|
@ -76,6 +76,16 @@ struct Options {
|
||||||
raw(hidden = "true")
|
raw(hidden = "true")
|
||||||
)]
|
)]
|
||||||
ignore_global: bool,
|
ignore_global: bool,
|
||||||
|
|
||||||
|
#[structopt(long, raw(overrides_with = r#""ignore-parent""#))]
|
||||||
|
/// Don't respect ignore files in parent directories.
|
||||||
|
no_ignore_parent: bool,
|
||||||
|
#[structopt(
|
||||||
|
long,
|
||||||
|
raw(overrides_with = r#""no-ignore-parent""#),
|
||||||
|
raw(hidden = "true")
|
||||||
|
)]
|
||||||
|
ignore_parent: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Options {
|
impl Options {
|
||||||
|
@ -116,6 +126,16 @@ impl Options {
|
||||||
.or_else(|| self.ignore_files())
|
.or_else(|| self.ignore_files())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn ignore_parent(&self) -> Option<bool> {
|
||||||
|
match (self.no_ignore_parent, self.ignore_parent) {
|
||||||
|
(true, false) => Some(false),
|
||||||
|
(false, true) => Some(true),
|
||||||
|
(false, false) => None,
|
||||||
|
(_, _) => unreachable!("StructOpt should make this impossible"),
|
||||||
|
}
|
||||||
|
.or_else(|| self.ignore_files())
|
||||||
|
}
|
||||||
|
|
||||||
fn ignore_files(&self) -> Option<bool> {
|
fn ignore_files(&self) -> Option<bool> {
|
||||||
match (self.no_ignore, self.ignore) {
|
match (self.no_ignore, self.ignore) {
|
||||||
(true, false) => Some(false),
|
(true, false) => Some(false),
|
||||||
|
@ -142,7 +162,8 @@ fn run() -> Result<(), failure::Error> {
|
||||||
walk.threads(options.threads)
|
walk.threads(options.threads)
|
||||||
.hidden(options.ignore_hidden().unwrap_or(true))
|
.hidden(options.ignore_hidden().unwrap_or(true))
|
||||||
.ignore(options.ignore_dot().unwrap_or(true))
|
.ignore(options.ignore_dot().unwrap_or(true))
|
||||||
.git_global(options.ignore_global().unwrap_or(true));
|
.git_global(options.ignore_global().unwrap_or(true))
|
||||||
|
.parents(options.ignore_parent().unwrap_or(true));
|
||||||
// TODO Add build_parallel for options.threads != 1
|
// TODO Add build_parallel for options.threads != 1
|
||||||
for entry in walk.build() {
|
for entry in walk.build() {
|
||||||
let entry = entry?;
|
let entry = entry?;
|
||||||
|
|
Loading…
Reference in a new issue