Skip to content

Commit

Permalink
Add --strict argument for cli (#219)
Browse files Browse the repository at this point in the history
Resolved #218
  • Loading branch information
JustAnotherID authored Oct 13, 2024
1 parent 79359e8 commit 04eb0f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions autocorrect-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ pub(crate) struct Cli {
help = "Disable diff background color for diff output."
)]
pub no_diff_bg_color: bool,

#[clap(
long,
help = "Strict mode will cause warnings to return a non-zero value.",
default_value = "false"
)]
pub strict: bool,
}

#[derive(Debug, Subcommand, Clone)]
Expand Down
4 changes: 4 additions & 0 deletions autocorrect-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ where
// Exit with code = 1
std::process::exit(1);
}
if cli.strict && _warn_count > 0 {
// Exit with code = 1
std::process::exit(1);
}
} else if cli.formatter == cli::OutputFormatter::Json {
log::info!("{}", autocorrect::json::to_lint_results_json(lint_results));
} else {
Expand Down

0 comments on commit 04eb0f1

Please sign in to comment.