mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-01 17:32:25 +00:00
Add exit-zero
This commit is contained in:
parent
1fb3db92f1
commit
8b1c4fce6b
1 changed files with 17 additions and 3 deletions
|
@ -1,9 +1,10 @@
|
|||
use std::path::{Path, PathBuf};
|
||||
use std::process::ExitCode;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::time::Instant;
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::{Parser, ValueHint};
|
||||
use clap::Parser;
|
||||
use colored::Colorize;
|
||||
use log::{debug, error};
|
||||
use notify::{raw_watcher, RecursiveMode, Watcher};
|
||||
|
@ -28,6 +29,8 @@ struct Cli {
|
|||
#[clap(short, long, action)]
|
||||
quiet: bool,
|
||||
#[clap(short, long, action)]
|
||||
exit_zero: bool,
|
||||
#[clap(short, long, action)]
|
||||
watch: bool,
|
||||
#[clap(short, long, action)]
|
||||
no_cache: bool,
|
||||
|
@ -92,7 +95,7 @@ fn report_continuously(messages: &[Message]) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
fn inner_main() -> Result<ExitCode> {
|
||||
let cli = Cli::parse();
|
||||
|
||||
set_up_logging(cli.verbose)?;
|
||||
|
@ -141,7 +144,18 @@ fn main() -> Result<()> {
|
|||
if !cli.quiet {
|
||||
report_once(&messages)?;
|
||||
}
|
||||
|
||||
if !messages.is_empty() && !cli.exit_zero {
|
||||
return Ok(ExitCode::FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(ExitCode::SUCCESS)
|
||||
}
|
||||
|
||||
fn main() -> ExitCode {
|
||||
match inner_main() {
|
||||
Ok(code) => code,
|
||||
Err(_) => ExitCode::FAILURE,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue