mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 20:48:43 +00:00
Show prompt for confirm
This commit is contained in:
parent
7f0c818313
commit
52c0213d98
1 changed files with 4 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
use std::io::{stderr, stdin, Write};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
|
@ -194,9 +195,11 @@ pub fn get_install_path<P: AsRef<Path>>(install_path: Option<P>) -> Option<PathB
|
||||||
pub fn confirm() -> Result<(), BinstallError> {
|
pub fn confirm() -> Result<(), BinstallError> {
|
||||||
loop {
|
loop {
|
||||||
info!("Do you wish to continue? yes/no");
|
info!("Do you wish to continue? yes/no");
|
||||||
|
eprint!("? ");
|
||||||
|
stderr().flush().ok();
|
||||||
|
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
std::io::stdin().read_line(&mut input).unwrap();
|
stdin().read_line(&mut input).unwrap();
|
||||||
|
|
||||||
match input.as_str().trim() {
|
match input.as_str().trim() {
|
||||||
"yes" | "y" | "YES" | "Y" => break Ok(()),
|
"yes" | "y" | "YES" | "Y" => break Ok(()),
|
||||||
|
|
Loading…
Add table
Reference in a new issue