Skip to content

Commit 7dfca7f

Browse files
authored
fix(cli): use line-based stdin read for gateway recreate prompt (#292)
1 parent 0aa4dda commit 7dfca7f

File tree

1 file changed

+18
-7
lines changed
  • crates/openshell-cli/src

1 file changed

+18
-7
lines changed

crates/openshell-cli/src/run.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,22 +1337,33 @@ pub async fn gateway_admin_deploy(
13371337
openshell_bootstrap::check_existing_deployment(name, remote_opts.as_ref()).await?
13381338
{
13391339
if !should_recreate {
1340-
let interactive = std::io::stderr().is_terminal();
1340+
let interactive = std::io::stdin().is_terminal() && std::io::stderr().is_terminal();
13411341
if interactive {
13421342
let status = if existing.container_running {
13431343
"running"
1344-
} else {
1344+
} else if existing.container_exists {
13451345
"stopped"
1346+
} else {
1347+
"volume only"
13461348
};
1349+
eprintln!();
13471350
eprintln!(
13481351
"{} Gateway '{name}' already exists ({status}).",
13491352
"!".yellow().bold()
13501353
);
1351-
should_recreate = Confirm::new()
1352-
.with_prompt("Destroy and recreate it?")
1353-
.default(false)
1354-
.interact()
1355-
.into_diagnostic()?;
1354+
if let Some(image) = &existing.container_image {
1355+
eprintln!(" {} {}", "Image:".dimmed(), image);
1356+
}
1357+
eprintln!();
1358+
eprint!("Destroy and recreate? [y/N] ");
1359+
std::io::stderr().flush().ok();
1360+
let mut input = String::new();
1361+
std::io::stdin()
1362+
.read_line(&mut input)
1363+
.into_diagnostic()
1364+
.wrap_err("failed to read user input")?;
1365+
let choice = input.trim().to_lowercase();
1366+
should_recreate = choice == "y" || choice == "yes";
13561367
if !should_recreate {
13571368
eprintln!("Keeping existing gateway.");
13581369
return Ok(());

0 commit comments

Comments
 (0)