Skip to content

Commit

Permalink
Remove deprecated CLI option --format (astral-sh#10170)
Browse files Browse the repository at this point in the history
Co-authored-by: Tibor Reiss <tibor.reiss@gmail.com>
  • Loading branch information
2 people authored and nkxxll committed Mar 4, 2024
1 parent 791c97d commit dd6499a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
8 changes: 0 additions & 8 deletions crates/ruff/src/args.rs
Expand Up @@ -63,10 +63,6 @@ pub enum Command {
/// Output format
#[arg(long, value_enum, default_value = "text")]
output_format: HelpFormat,

/// Output format (Deprecated: Use `--output-format` instead).
#[arg(long, value_enum, conflicts_with = "output_format", hide = true)]
format: Option<HelpFormat>,
},
/// List or describe the available configuration options.
Config { option: Option<String> },
Expand All @@ -75,10 +71,6 @@ pub enum Command {
/// Output format
#[arg(long, value_enum, default_value = "text")]
output_format: HelpFormat,

/// Output format (Deprecated: Use `--output-format` instead).
#[arg(long, value_enum, conflicts_with = "output_format", hide = true)]
format: Option<HelpFormat>,
},
/// Clear any caches in the current directory and any subdirectories.
#[clap(alias = "--clean")]
Expand Down
21 changes: 3 additions & 18 deletions crates/ruff/src/lib.rs
Expand Up @@ -18,7 +18,7 @@ use ruff_linter::settings::types::SerializationFormat;
use ruff_linter::{fs, warn_user, warn_user_once};
use ruff_workspace::Settings;

use crate::args::{Args, CheckCommand, Command, FormatCommand, HelpFormat};
use crate::args::{Args, CheckCommand, Command, FormatCommand};
use crate::printer::{Flags as PrinterFlags, Printer};

pub mod args;
Expand Down Expand Up @@ -114,15 +114,6 @@ fn resolve_default_files(files: Vec<PathBuf>, is_stdin: bool) -> Vec<PathBuf> {
}
}

/// Get the actual value of the `format` desired from either `output_format`
/// or `format`, and warn the user if they're using the deprecated form.
fn resolve_help_output_format(output_format: HelpFormat, format: Option<HelpFormat>) -> HelpFormat {
if format.is_some() {
warn_user!("The `--format` argument is deprecated. Use `--output-format` instead.");
}
format.unwrap_or(output_format)
}

pub fn run(
Args {
command,
Expand Down Expand Up @@ -171,10 +162,8 @@ pub fn run(
Command::Rule {
rule,
all,
format,
mut output_format,
output_format,
} => {
output_format = resolve_help_output_format(output_format, format);
if all {
commands::rule::rules(output_format)?;
}
Expand All @@ -187,11 +176,7 @@ pub fn run(
commands::config::config(option.as_deref())?;
Ok(ExitStatus::Success)
}
Command::Linter {
format,
mut output_format,
} => {
output_format = resolve_help_output_format(output_format, format);
Command::Linter { output_format } => {
commands::linter::linter(output_format)?;
Ok(ExitStatus::Success)
}
Expand Down

0 comments on commit dd6499a

Please sign in to comment.