Skip to content

Commit

Permalink
Move output nearer to where it's used
Browse files Browse the repository at this point in the history
  • Loading branch information
havenwood committed Nov 21, 2024
1 parent f18f3ff commit 5613b8b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ fn main() -> Result<()> {
let delimiter = unescape(&args.delimiter)?;
let input = Input::from_args(&args.input)?;
let source = input.source();
let mut output = Output::from_args(&args.output)?;

let reader = input.get_reader(&source)?;
let options = Options::new(args.case, args.sort);
Expand All @@ -28,10 +27,12 @@ fn main() -> Result<()> {
let word_tally = WordTally::new(reader, options, filters);

if args.verbose {
let mut verbose = Verbose::new(Output::stderr(), &word_tally, &delimiter, &source);
let stderr = Output::stderr();
let mut verbose = Verbose::new(stderr, &word_tally, &delimiter, &source);
verbose.log()?;
}

let mut output = Output::from_args(&args.output)?;
for (word, count) in word_tally.tally() {
output.write_line(&format!("{word}{delimiter}{count}\n"))?;
}
Expand Down

0 comments on commit 5613b8b

Please sign in to comment.