make fix cli accept a - argument to indicate reading from stdin

I'm pretty sure we had this in the past... no?
I have my helix set up to respect this argument, so it's weird it stopped working at some point.
This commit is contained in:
liquidex 2024-09-29 00:14:11 +02:00
parent c2a4b0169b
commit bbf5c3b529

View file

@ -134,7 +134,11 @@ pub fn fix_file(
pub fn fix_file_cli(fix_args: FixArgs) -> anyhow::Result<()> {
let utf8_filename = fix_args.file.to_string_lossy().into_owned();
let file = std::fs::read_to_string(&fix_args.file).context("cannot read file to fix")?;
let file = if utf8_filename == "-" {
std::io::read_to_string(std::io::stdin().lock()).context("cannot read file from stdin")?
} else {
std::fs::read_to_string(&fix_args.file).context("cannot read file to fix")?
};
let mut treehouse = Treehouse::new();
let mut diagnostics = vec![];