diff --git a/crates/config/src/formatter.rs b/crates/config/src/formatter.rs index d7dcd73..468b0ed 100644 --- a/crates/config/src/formatter.rs +++ b/crates/config/src/formatter.rs @@ -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, } diff --git a/crates/formatter/src/formating.rs b/crates/formatter/src/formating.rs index 9c8aa95..370f97d 100644 --- a/crates/formatter/src/formating.rs +++ b/crates/formatter/src/formating.rs @@ -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.