Error message for stdin
This commit is contained in:
parent
df688646de
commit
dbb44dffb4
|
|
@ -10,4 +10,8 @@ pub struct FormatterConfig {
|
||||||
/// Export the config
|
/// Export the config
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
pub config: bool,
|
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.
|
// 2. Read the entire stdin into a string.
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
|
if args.stdin {
|
||||||
io::stdin()
|
io::stdin()
|
||||||
.read_to_string(&mut input)
|
.read_to_string(&mut input)
|
||||||
.context("Failed to read stdin")?;
|
.context("Failed to read stdin")?;
|
||||||
|
} else {
|
||||||
|
unimplemented!("Use --stdin")
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// 3. Apply the patterns sequentially.
|
// 3. Apply the patterns sequentially.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue