use std::io::Read; use tally::count; fn main() { let path = std::env::args().nth(1); let text = match &path { Some(path) => std::fs::read_to_string(path).unwrap(), None => { let mut text = String::new(); std::io::stdin().read_to_string(&mut text).unwrap(); text } }; let c = count(&text); let name = path.as_deref().unwrap_or("-"); println!("{:>8} {:>8} {:>8} {name}", c.lines, c.words, c.bytes); }