From b04cf2b77bbc829fd4d1e0f78751b03d1292836f Mon Sep 17 00:00:00 2001 From: SteveBeeblebrox <41750582+SteveBeeblebrox@users.noreply.github.com> Date: Mon, 6 Jun 2022 19:55:03 -0600 Subject: [PATCH] Dash for std I/O --- src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 84297e3..0a2c81a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,15 +64,15 @@ fn main() { // Determine input file (or stdin) let (input_file, input_text) = match matches.value_of("INPUT") { - Some(value) => (Some(String::from(value)), fs::read_to_string(value).expect("Error reading target file")), - None => { + Some("-") | None => { let stdin = io::stdin(); let mut stdin = stdin.lock(); let mut line = String::new(); stdin.read_to_string(&mut line).expect("Error reading stdin"); (None, String::from(line)) - } + }, + Some(value) => (Some(String::from(value)), fs::read_to_string(value).expect("Error reading target file")) }; let html = matches.occurrences_of("html") > 0; @@ -87,7 +87,7 @@ fn main() { }; match matches.value_of("output") { - Some("") if matches.occurrences_of("output") > 0 => print!("{}", result.as_str()), + Some("-") | Some("") if matches.occurrences_of("output") > 0 => print!("{}", result.as_str()), None | Some("") => { match input_file { Some(input_file) => {