Error message for stdin
This commit is contained in:
parent
df688646de
commit
dbb44dffb4
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in New Issue