Skip to content

Commit 89a8215

Browse files
MichaReiserAlexWaygood
authored andcommitted
Remove error messages for removed CLI aliases (#12833)
Closes #10171
1 parent 202c6a6 commit 89a8215

File tree

1 file changed

+3
-46
lines changed

1 file changed

+3
-46
lines changed

crates/ruff/src/main.rs

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1+
use std::io::Write;
12
use std::process::ExitCode;
23

3-
use clap::{Parser, Subcommand};
4+
use clap::Parser;
45
use colored::Colorize;
5-
use log::error;
6-
use std::io::Write;
76

8-
use ruff::args::{Args, Command};
7+
use ruff::args::Args;
98
use ruff::{run, ExitStatus};
10-
use ruff_linter::logging::{set_up_logging, LogLevel};
119

1210
#[cfg(target_os = "windows")]
1311
#[global_allocator]
@@ -41,47 +39,6 @@ pub fn main() -> ExitCode {
4139
let args = wild::args_os();
4240
let args = argfile::expand_args_from(args, argfile::parse_fromfile, argfile::PREFIX).unwrap();
4341

44-
// We can't use `warn_user` here because logging isn't set up at this point
45-
// and we also don't know if the user runs ruff with quiet.
46-
// Keep the message and pass it to `run` that is responsible for emitting the warning.
47-
let deprecated_alias_error = match args.get(1).and_then(|arg| arg.to_str()) {
48-
// Deprecated aliases that are handled by clap
49-
Some("--explain") => {
50-
Some("`ruff --explain <RULE>` has been removed. Use `ruff rule <RULE>` instead.")
51-
}
52-
Some("--clean") => {
53-
Some("`ruff --clean` has been removed. Use `ruff clean` instead.")
54-
}
55-
Some("--generate-shell-completion") => {
56-
Some("`ruff --generate-shell-completion <SHELL>` has been removed. Use `ruff generate-shell-completion <SHELL>` instead.")
57-
}
58-
// Deprecated `ruff` alias to `ruff check`
59-
// Clap doesn't support default subcommands but we want to run `check` by
60-
// default for convenience and backwards-compatibility, so we just
61-
// preprocess the arguments accordingly before passing them to Clap.
62-
Some(arg) if !Command::has_subcommand(arg)
63-
&& arg != "-h"
64-
&& arg != "--help"
65-
&& arg != "-V"
66-
&& arg != "--version"
67-
&& arg != "help" => {
68-
{
69-
Some("`ruff <path>` has been removed. Use `ruff check <path>` instead.")
70-
}
71-
},
72-
_ => None
73-
};
74-
75-
if let Some(error) = deprecated_alias_error {
76-
#[allow(clippy::print_stderr)]
77-
if set_up_logging(LogLevel::Default).is_ok() {
78-
error!("{}", error);
79-
} else {
80-
eprintln!("{}", error.red().bold());
81-
}
82-
return ExitCode::FAILURE;
83-
}
84-
8542
let args = Args::parse_from(args);
8643

8744
match run(args) {

0 commit comments

Comments
 (0)