mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 05:45:24 +00:00
Move stdin formatting to its own command file (#6981)
## Summary This is similar to `commands::check` vs. `commands::check_stdin`, and gets the logic out of the parent file (`lib.rs`). It also ensures that we avoid formatting files that should be excluded when `--force-exclude` is provided.
This commit is contained in:
parent
34221346c1
commit
25c374856a
5 changed files with 51 additions and 20 deletions
|
@ -1,4 +1,3 @@
|
|||
use std::io::{self, Read};
|
||||
use std::path::Path;
|
||||
|
||||
use anyhow::Result;
|
||||
|
@ -9,13 +8,7 @@ use ruff_workspace::resolver::{python_file_at_path, PyprojectConfig};
|
|||
|
||||
use crate::args::Overrides;
|
||||
use crate::diagnostics::{lint_stdin, Diagnostics};
|
||||
|
||||
/// Read a `String` from `stdin`.
|
||||
pub(crate) fn read_from_stdin() -> Result<String> {
|
||||
let mut buffer = String::new();
|
||||
io::stdin().lock().read_to_string(&mut buffer)?;
|
||||
Ok(buffer)
|
||||
}
|
||||
use crate::stdin::read_from_stdin;
|
||||
|
||||
/// Run the linter over a single file, read from `stdin`.
|
||||
pub(crate) fn check_stdin(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue