Skip to content

Commit

Permalink
hotfix: untrimmed response
Browse files Browse the repository at this point in the history
  • Loading branch information
skilly-lily committed Nov 25, 2020
1 parent 3bea79b commit 4e7ef68
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"]
edition = "2018"

Expand Down
10 changes: 6 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl Confirm {
let mut new = self.prompt.clone();
new.push(' ');
new.push_str(optionbox);
new.push(':');
new.push_str(": ");
new
}

Expand All @@ -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)?)
}
}

Expand Down

0 comments on commit 4e7ef68

Please sign in to comment.