Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions crates/system-reinstall-bootc/src/prompt.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/// A variant of `println!` that flushes stdout.
macro_rules! println_flush {
($($arg:tt)*) => {
{
use std::io::Write;
println!($($arg)*);
std::io::stdout().flush().unwrap();
}
};
}

use crate::{btrfs, lvm, prompt, users::get_all_users_keys};
use anyhow::{ensure, Context, Result};

Expand Down Expand Up @@ -46,7 +57,7 @@ fn prompt_user_selection(

pub(crate) fn reboot() -> Result<()> {
let delay_seconds = 10;
println!(
println_flush!(
"Operation complete, rebooting in {delay_seconds} seconds. Press Ctrl-C to cancel reboot, or press enter to continue immediately.",
);

Expand All @@ -70,13 +81,13 @@ pub(crate) fn reboot() -> Result<()> {
/// final prompting UX in https://github.com/bootc-dev/bootc/discussions/1060
pub(crate) fn temporary_developer_protection_prompt() -> Result<()> {
// Print an empty line so that the warning stands out from the rest of the output
println!();
println_flush!();

let prompt = "NOTICE: This will replace the installed operating system and reboot. Are you sure you want to continue?";
let answer = ask_yes_no(prompt, false)?;

if !answer {
println!("Exiting without reinstalling the system.");
println_flush!("Exiting without reinstalling the system.");
std::process::exit(0);
}

Expand Down