Skip to content

Commit

Permalink
Merge pull request #52 from GabrielBrandao1618/master
Browse files Browse the repository at this point in the history
feat(cli): handle creation prompt defaults to yes
  • Loading branch information
EduardoRodriguesF authored Jul 25, 2024
2 parents 9057a11 + 31effbc commit dadb577
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,15 @@ impl Ctx {
}

pub fn confirm(&self, message: &str) -> bool {
println!("{} {}", message, "(y/n)".dimmed());
println!("{} {}", message, "(Y/n)".dimmed());

std::io::stdout().flush().unwrap();

let term = console::Term::stdout();
let ch = term.read_char().unwrap_or('n').to_ascii_lowercase();
if ch == '\n' {
return true;
}

ch == 'y'
}
Expand Down

0 comments on commit dadb577

Please sign in to comment.