Source code for devops_utils.core.io
"""Small I/O helpers shared across surfaces."""
import sys
[docs]
def input_confirm(message: str) -> bool:
"""Wait for user input, loop until a valid user input."""
_message = f"{message} y/n\n" if message else "Confirm operation? y/n\n"
response = input(_message)
while response.lower().strip() not in ("yes", "y", "n", "no"):
response = input(f"Please, enter a valid input! {_message}\n")
return response.startswith("y")
[docs]
def eprint(*args, **kwargs) -> None:
"""Print to stderr."""
print(*args, file=sys.stderr, **kwargs)