Skip to content

Commit

Permalink
Merge pull request #66 from triarius/triarius/isatty
Browse files Browse the repository at this point in the history
Use isatty to not print new line if stdout is not a tty
  • Loading branch information
triarius authored May 13, 2024
2 parents 83e151d + ea538f4 commit 705d978
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
mod passphrase;
mod words;

use std::io::IsTerminal;

use clap::Parser;
use eyre::Result;

Expand All @@ -25,10 +27,14 @@ fn main() -> Result<()> {
let mut words: Vec<String> = words::list(args.dict_path)?;
let mut rng = rand::thread_rng();

println!(
print!(
"{}",
passphrase::new(&mut rng, &mut words, args.num_words, &args.separator)
);

if std::io::stdout().is_terminal() {
println!();
}

Ok(())
}

0 comments on commit 705d978

Please sign in to comment.