Error message for stdin

This commit is contained in:
Dandaedre 2026-04-23 15:44:26 +02:00
parent df688646de
commit dbb44dffb4
2 changed files with 11 additions and 3 deletions

View File

@ -10,4 +10,8 @@ pub struct FormatterConfig {
/// Export the config
#[arg(short, long)]
pub config: bool,
/// Take the arguments via stdin
#[arg(long)]
pub stdin: bool,
}

View File

@ -66,9 +66,13 @@ pub fn format_file(args: &FormatterConfig, _config: &Config) -> Result<()> {
// 2. Read the entire stdin into a string.
// ------------------------------------------------------------------
let mut input = String::new();
io::stdin()
.read_to_string(&mut input)
.context("Failed to read stdin")?;
if args.stdin {
io::stdin()
.read_to_string(&mut input)
.context("Failed to read stdin")?;
} else {
unimplemented!("Use --stdin")
}
// ------------------------------------------------------------------
// 3. Apply the patterns sequentially.