fix(template): use sys.stdin.readline() for snapshot confirm prompt
input() with a prompt string on some terminals (zsh + Linux Mint) echoes ^M and the prompt doesn't flush before reading, causing the prompt to appear stuck or not accept input. Replace with explicit sys.stdout.write()+flush() + sys.stdin.readline() which guarantees the prompt is flushed before blocking on stdin, and readline() + .strip() handles both \n and \r\n line endings correctly. Tests updated to use CliRunner(input=) which populates sys.stdin inside the runner context (monkeypatching sys.stdin.readline directly is ignored by CliRunner which replaces sys.stdin entirely). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -60,6 +60,7 @@ import json
|
||||
import shutil
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
from datetime import UTC, datetime
|
||||
@@ -671,8 +672,10 @@ Register-ScheduledTask -TaskName 'CI-StaticIp' `
|
||||
if recreate_snapshot:
|
||||
do_recreate = True
|
||||
else:
|
||||
raw = input(f"[prepare-win] Delete and recreate '{snapshot}'? [y/N] ")
|
||||
do_recreate = raw.strip().rstrip("\r").lower() in ("y", "yes")
|
||||
sys.stdout.write(f"[prepare-win] Delete and recreate '{snapshot}'? [y/N] ")
|
||||
sys.stdout.flush()
|
||||
raw = sys.stdin.readline()
|
||||
do_recreate = raw.strip().lower() in ("y", "yes")
|
||||
if not do_recreate:
|
||||
click.echo("[prepare-win] Keeping existing snapshot. Provisioning complete.")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user