mirror of https://github.com/astral-sh/ruff
Remove output-file and target-version from formatter CLI
This commit is contained in:
parent
154fe7bdcc
commit
bbeda1a8ab
|
|
@ -338,12 +338,6 @@ pub struct FormatCommand {
|
||||||
/// files would have been modified, and zero otherwise.
|
/// files would have been modified, and zero otherwise.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub check: bool,
|
pub check: bool,
|
||||||
/// Specify file to write the formatter output to (default: stdout).
|
|
||||||
#[arg(short, long)]
|
|
||||||
pub output_file: Option<PathBuf>,
|
|
||||||
/// The minimum Python version that should be supported.
|
|
||||||
#[arg(long, value_enum)]
|
|
||||||
pub target_version: Option<PythonVersion>,
|
|
||||||
/// Path to the `pyproject.toml` or `ruff.toml` file to use for configuration.
|
/// Path to the `pyproject.toml` or `ruff.toml` file to use for configuration.
|
||||||
#[arg(long, conflicts_with = "isolated")]
|
#[arg(long, conflicts_with = "isolated")]
|
||||||
pub config: Option<PathBuf>,
|
pub config: Option<PathBuf>,
|
||||||
|
|
@ -494,7 +488,6 @@ impl FormatCommand {
|
||||||
config: self.config,
|
config: self.config,
|
||||||
files: self.files,
|
files: self.files,
|
||||||
isolated: self.isolated,
|
isolated: self.isolated,
|
||||||
output_file: self.output_file,
|
|
||||||
stdin_filename: self.stdin_filename,
|
stdin_filename: self.stdin_filename,
|
||||||
},
|
},
|
||||||
Overrides {
|
Overrides {
|
||||||
|
|
@ -504,7 +497,6 @@ impl FormatCommand {
|
||||||
self.no_respect_gitignore,
|
self.no_respect_gitignore,
|
||||||
),
|
),
|
||||||
force_exclude: resolve_bool_arg(self.force_exclude, self.no_force_exclude),
|
force_exclude: resolve_bool_arg(self.force_exclude, self.no_force_exclude),
|
||||||
target_version: self.target_version,
|
|
||||||
// Unsupported on the formatter CLI, but required on `Overrides`.
|
// Unsupported on the formatter CLI, but required on `Overrides`.
|
||||||
..Overrides::default()
|
..Overrides::default()
|
||||||
},
|
},
|
||||||
|
|
@ -556,7 +548,6 @@ pub struct FormatArguments {
|
||||||
pub config: Option<PathBuf>,
|
pub config: Option<PathBuf>,
|
||||||
pub files: Vec<PathBuf>,
|
pub files: Vec<PathBuf>,
|
||||||
pub isolated: bool,
|
pub isolated: bool,
|
||||||
pub output_file: Option<PathBuf>,
|
|
||||||
pub stdin_filename: Option<PathBuf>,
|
pub stdin_filename: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use std::fmt::{Display, Formatter};
|
use std::fmt::{Display, Formatter};
|
||||||
use std::fs::File;
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::{BufWriter, Write};
|
|
||||||
use std::num::NonZeroU16;
|
use std::num::NonZeroU16;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
@ -98,15 +96,10 @@ pub(crate) fn format(
|
||||||
|
|
||||||
// Report on the formatting changes.
|
// Report on the formatting changes.
|
||||||
if log_level >= LogLevel::Default {
|
if log_level >= LogLevel::Default {
|
||||||
let mut writer: Box<dyn Write> = match &cli.output_file {
|
#[allow(clippy::print_stdout)]
|
||||||
Some(path) => {
|
{
|
||||||
colored::control::set_override(false);
|
println!("{summary}");
|
||||||
let file = File::create(path)?;
|
}
|
||||||
Box::new(BufWriter::new(file))
|
|
||||||
}
|
|
||||||
_ => Box::new(BufWriter::new(io::stdout())),
|
|
||||||
};
|
|
||||||
writeln!(writer, "{summary}")?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match mode {
|
match mode {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue