diff --git a/Cargo.lock b/Cargo.lock index 1228f96..97f9938 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "confirm-rs" -version = "0.1.1" +version = "0.1.2" dependencies = [ "anyhow", "atty", diff --git a/Cargo.toml b/Cargo.toml index a7b7529..96c0430 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ license = "Unlicense" homepage = "https://github.com/scruffystuffs/confirm" repository = "https://github.com/scruffystuffs/confirm" documentation = "https://github.com/scruffystuffs/confirm/README.md" -version = "0.1.1" +version = "0.1.2" authors = ["Wesley Van Melle "] edition = "2018" diff --git a/src/main.rs b/src/main.rs index 821ac5c..5c322ee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -166,7 +166,7 @@ impl Confirm { let mut new = self.prompt.clone(); new.push(' '); new.push_str(optionbox); - new.push(':'); + new.push_str(": "); new } @@ -186,12 +186,14 @@ impl Confirm { } }; - if input_buf.trim().is_empty() { + let response = input_buf.trim(); + + if response.is_empty() { Ok(self.default_response) - } else if self.use_full_words && !is_full_word(&input_buf) { + } else if self.use_full_words && !is_full_word(response) { Err(anyhow!("Please type yes or no")) } else { - Ok(Answer::from_str(&input_buf)?) + Ok(Answer::from_str(response)?) } }