Skip to content

Commit

Permalink
Print confirmation message to stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Nov 16, 2023
1 parent 4e44d02 commit 54e27bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
6 changes: 1 addition & 5 deletions src/recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,8 @@ impl<'src, D> Recipe<'src, D> {

pub(crate) fn confirm(&self) -> RunResult<'src, bool> {
if self.attributes.contains(&Attribute::Confirm) {
print!("Run recipe `{}`? ", self.name);
eprint!("Run recipe `{}`? ", self.name);
let mut line = String::new();
std::io::stdout().flush().map_err(|e| Error::Io {
recipe: self.name(),
io_error: e,
})?;
std::io::stdin()
.read_line(&mut line)
.map_err(|e| Error::Io {
Expand Down
15 changes: 7 additions & 8 deletions tests/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ fn confirm_recipe() {
echo confirmed
",
)
.stderr("echo confirmed\n")
.stdout("Run recipe `requires_confirmation`? confirmed\n")
.stderr("Run recipe `requires_confirmation`? echo confirmed\n")
.stdout("confirmed\n")
.stdin("y")
.run();
}
Expand All @@ -64,8 +64,8 @@ fn recipe_with_confirm_recipe_dependency() {
echo confirmed
",
)
.stderr("echo confirmed\necho confirmed2\n")
.stdout("Run recipe `requires_confirmation`? confirmed\nconfirmed2\n")
.stderr("Run recipe `requires_confirmation`? echo confirmed\necho confirmed2\n")
.stdout("confirmed\nconfirmed2\n")
.stdin("y")
.run();
}
Expand All @@ -80,8 +80,8 @@ fn do_not_confirm_recipe() {
echo confirmed
",
)
.stderr("error: Recipe `requires_confirmation` was not confirmed\n")
.stdout("Run recipe `requires_confirmation`? ")
.stderr("Run recipe `requires_confirmation`? error: Recipe `requires_confirmation` was not confirmed\n")
.stdout("")
.status(1)
.run();
}
Expand All @@ -99,8 +99,7 @@ fn do_not_confirm_recipe_with_confirm_recipe_dependency() {
echo confirmed
",
)
.stderr("error: Recipe `requires_confirmation` was not confirmed\n")
.stdout("Run recipe `requires_confirmation`? ")
.stderr("Run recipe `requires_confirmation`? error: Recipe `requires_confirmation` was not confirmed\n")
.status(1)
.run();
}

0 comments on commit 54e27bd

Please sign in to comment.