Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --strict argument for cli #219

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading