pkgs/cli: machines install handle invalid character

Re-request prompt, if invalid character is specified.
None is still treated as no as per CLI hint [y/N].
We now also accept Y/N.

Closes: #4475
This commit is contained in:
a-kenji
2025-07-24 21:57:44 +02:00
parent f5b4e44aed
commit 6cea3e6c60

View File

@@ -63,9 +63,17 @@ def install_command(args: argparse.Namespace) -> None:
raise ClanError(msg)
if not args.yes:
ask = input(f"Install {args.machine} to {target_host.target}? [y/N] ")
if ask != "y":
return None
while True:
ask = (
input(f"Install {args.machine} to {target_host.target}? [y/N] ")
.strip()
.lower()
)
if ask == "y":
break
if ask == "n" or ask == "":
return None
print(f"Invalid input '{ask}'. Please enter 'y' for yes or 'n' for no.")
if args.identity_file:
target_host = target_host.override(private_key=args.identity_file)