diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index 10a217e590..402196b894 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -10,12 +10,12 @@ ruff check . # New! Also works. ruff --explain E402 # Still works. - ruff explain E402 # New! Also works. (And preferred.) + ruff rule E402 # New! Also works. (And preferred.) # Oops! The command has to come first. ruff --format json --explain E402 # No longer works. ruff --explain E402 --format json # Works! - ruff explain E402 --format json # Works! (And preferred.) + ruff rule E402 --format json # Works! (And preferred.) This change is largely backwards compatible -- most users should experience no change in behavior. However, please note the following exceptions: @@ -23,13 +23,13 @@ no change in behavior. However, please note the following exceptions: * Subcommands will now fail when invoked with unsupported arguments, instead of silently ignoring them. For example, the following will now fail: - ruff --explain E402 --respect-gitignore + ruff --clean --respect-gitignore - (the `explain` command doesn't support `--respect-gitignore`.) + (the `clean` command doesn't support `--respect-gitignore`.) * The semantics of `ruff ` have changed slightly when `` is a valid subcommand. - For example, prior to this release, running `ruff explain` would run `ruff` over a file or - directory called `explain`. Now, `ruff explain` would invoke the `explain` subcommand. + For example, prior to this release, running `ruff rule` would run `ruff` over a file or + directory called `rule`. Now, `ruff rule` would invoke the `rule` subcommand. * Scripts that invoke ruff should supply `--` before any positional arguments. (The semantics of `ruff -- ` have not changed.) diff --git a/README.md b/README.md index c52aa2ca05..2f6982cfe4 100644 --- a/README.md +++ b/README.md @@ -369,10 +369,10 @@ Ruff: An extremely fast Python linter. Usage: ruff [OPTIONS] Commands: - check Run Ruff on the given files or directories (default) - explain Explain a rule - clean Clear any caches in the current directory and any subdirectories - help Print this message or the help of the given subcommand(s) + check Run Ruff on the given files or directories (default) + rule Explain a rule + clean Clear any caches in the current directory and any subdirectories + help Print this message or the help of the given subcommand(s) Options: -h, --help Print help diff --git a/ruff_cli/src/args.rs b/ruff_cli/src/args.rs index edfa92b6be..b821468ee3 100644 --- a/ruff_cli/src/args.rs +++ b/ruff_cli/src/args.rs @@ -33,7 +33,7 @@ pub enum Command { Check(CheckArgs), /// Explain a rule. #[clap(alias = "--explain")] - Explain { + Rule { #[arg(value_parser=Rule::from_code)] rule: &'static Rule, diff --git a/ruff_cli/src/commands.rs b/ruff_cli/src/commands.rs index 7cbff1e277..1f4db0dbd7 100644 --- a/ruff_cli/src/commands.rs +++ b/ruff_cli/src/commands.rs @@ -268,7 +268,7 @@ struct Explanation<'a> { } /// Explain a `Rule` to the user. -pub fn explain(rule: &Rule, format: HelpFormat) -> Result<()> { +pub fn rule(rule: &Rule, format: HelpFormat) -> Result<()> { let (linter, _) = Linter::parse_code(rule.code()).unwrap(); match format { HelpFormat::Text => { diff --git a/ruff_cli/src/main.rs b/ruff_cli/src/main.rs index a3a2542720..a62db5f2ab 100644 --- a/ruff_cli/src/main.rs +++ b/ruff_cli/src/main.rs @@ -77,7 +77,7 @@ quoting the executed command, along with the relevant file contents and `pyproje set_up_logging(&log_level)?; match command { - Command::Explain { rule, format } => commands::explain(rule, format)?, + Command::Rule { rule, format } => commands::rule(rule, format)?, Command::Clean => commands::clean(log_level)?, Command::GenerateShellCompletion { shell } => { shell.generate(&mut Args::command(), &mut io::stdout()); @@ -272,7 +272,7 @@ fn check(args: CheckArgs, log_level: LogLevel) -> Result { fn rewrite_legacy_subcommand(cmd: &str) -> &str { match cmd { - "--explain" => "explain", + "--explain" => "rule", "--clean" => "clean", "--generate-shell-completion" => "generate-shell-completion", cmd => cmd,