diff --git a/crates/ruff/src/main.rs b/crates/ruff/src/main.rs index f1d066378800a..2271cca49b617 100644 --- a/crates/ruff/src/main.rs +++ b/crates/ruff/src/main.rs @@ -1,13 +1,11 @@ +use std::io::Write; use std::process::ExitCode; -use clap::{Parser, Subcommand}; +use clap::Parser; use colored::Colorize; -use log::error; -use std::io::Write; -use ruff::args::{Args, Command}; +use ruff::args::Args; use ruff::{run, ExitStatus}; -use ruff_linter::logging::{set_up_logging, LogLevel}; #[cfg(target_os = "windows")] #[global_allocator] @@ -41,47 +39,6 @@ pub fn main() -> ExitCode { let args = wild::args_os(); let args = argfile::expand_args_from(args, argfile::parse_fromfile, argfile::PREFIX).unwrap(); - // We can't use `warn_user` here because logging isn't set up at this point - // and we also don't know if the user runs ruff with quiet. - // Keep the message and pass it to `run` that is responsible for emitting the warning. - let deprecated_alias_error = match args.get(1).and_then(|arg| arg.to_str()) { - // Deprecated aliases that are handled by clap - Some("--explain") => { - Some("`ruff --explain ` has been removed. Use `ruff rule ` instead.") - } - Some("--clean") => { - Some("`ruff --clean` has been removed. Use `ruff clean` instead.") - } - Some("--generate-shell-completion") => { - Some("`ruff --generate-shell-completion ` has been removed. Use `ruff generate-shell-completion ` instead.") - } - // Deprecated `ruff` alias to `ruff check` - // Clap doesn't support default subcommands but we want to run `check` by - // default for convenience and backwards-compatibility, so we just - // preprocess the arguments accordingly before passing them to Clap. - Some(arg) if !Command::has_subcommand(arg) - && arg != "-h" - && arg != "--help" - && arg != "-V" - && arg != "--version" - && arg != "help" => { - { - Some("`ruff ` has been removed. Use `ruff check ` instead.") - } - }, - _ => None - }; - - if let Some(error) = deprecated_alias_error { - #[allow(clippy::print_stderr)] - if set_up_logging(LogLevel::Default).is_ok() { - error!("{}", error); - } else { - eprintln!("{}", error.red().bold()); - } - return ExitCode::FAILURE; - } - let args = Args::parse_from(args); match run(args) {