summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index b26289c..fe1d0eb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,6 +1,6 @@
use std::collections::HashSet;
use std::env::args;
-use std::io::{stdin, BufRead, BufReader};
+use std::io::{prelude::*, stdin, stdout, BufReader, BufWriter};
const HELP_MSG: &str = "Title-Case Tool\n\
-h | --help\t\t\tPrints this message\n\
@@ -46,11 +46,18 @@ fn main() {
// gather exceptions
let exceptions: HashSet<&'static str> = EXCEPTIONS.iter().cloned().collect();
- // read input and correct lines
+ // read input, correct lines, write output
+ let mut writer = BufWriter::new(stdout());
for line in BufReader::new(stdin()).lines() {
let line = line.expect("IO error");
- println!("{}", correct_line(&line, &ignorables, &exceptions));
+ writeln!(
+ &mut writer,
+ "{}",
+ correct_line(&line, &ignorables, &exceptions)
+ )
+ .expect("Failed to write output");
}
+ writer.flush().expect("Failed to write output");
}
/// Corrects a single line (title) based on placement and exceptions.