Skip to content

Commit

Permalink
Add --quote-style argument to ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
sciyoshi committed Nov 30, 2023
1 parent 041163a commit 54bc011
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/ruff_cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::path::PathBuf;

use clap::{command, Parser};
use regex::Regex;
use ruff_python_formatter::QuoteStyle;
use rustc_hash::FxHashMap;

use ruff_linter::line_width::LineLength;
Expand Down Expand Up @@ -417,6 +418,9 @@ pub struct FormatCommand {
/// Set the line-length.
#[arg(long, help_heading = "Format configuration")]
pub line_length: Option<LineLength>,
/// Set the quote-style.
#[arg(long, help_heading = "Format configuration")]
pub quote_style: Option<QuoteStyle>,
/// Ignore all configuration files.
#[arg(long, conflicts_with = "config", help_heading = "Miscellaneous")]
pub isolated: bool,
Expand Down Expand Up @@ -521,6 +525,7 @@ impl CheckCommand {
fixable: self.fixable,
ignore: self.ignore,
line_length: self.line_length,
quote_style: None,
per_file_ignores: self.per_file_ignores,
preview: resolve_bool_arg(self.preview, self.no_preview).map(PreviewMode::from),
respect_gitignore: resolve_bool_arg(
Expand Down Expand Up @@ -562,6 +567,7 @@ impl FormatCommand {
},
CliOverrides {
line_length: self.line_length,
quote_style: self.quote_style,
respect_gitignore: resolve_bool_arg(
self.respect_gitignore,
self.no_respect_gitignore,
Expand Down Expand Up @@ -637,6 +643,7 @@ pub struct CliOverrides {
pub fixable: Option<Vec<RuleSelector>>,
pub ignore: Option<Vec<RuleSelector>>,
pub line_length: Option<LineLength>,
pub quote_style: Option<QuoteStyle>,
pub per_file_ignores: Option<Vec<PatternPrefixPair>>,
pub extend_per_file_ignores: Option<Vec<PatternPrefixPair>>,
pub preview: Option<PreviewMode>,
Expand Down Expand Up @@ -718,6 +725,9 @@ impl ConfigurationTransformer for CliOverrides {
..config.lint.pycodestyle.unwrap_or_default()
});
}
if let Some(quote_style) = self.quote_style {
config.format.quote_style = Some(quote_style);
}
if let Some(preview) = &self.preview {
config.preview = Some(*preview);
config.lint.preview = Some(*preview);
Expand Down

0 comments on commit 54bc011

Please sign in to comment.