Skip to content

io

The io module provides interactive user input functions for CLI scripts.

Functions

Function Returns Description
io.confirm(msg, default=False) bool Prompt the user for a yes/no confirmation
io.prompt(msg, default="", secret=False) string Prompt the user for text input. Set secret=True to hide input (e.g. passwords)

Examples

Confirmation prompt

if io.confirm("Deploy to production?"):
    exec("kubectl apply -f prod.yaml")
else:
    print("Aborted.")

Confirmation with default

# Default to True — pressing Enter confirms
if io.confirm("Continue?", default=True):
    print("Continuing...")

Text prompt

name = io.prompt("Enter cluster name")
print("Deploying to:", name)

Prompt with default value

region = io.prompt("AWS region", default="us-east-1")
print("Using region:", region)

Secret input

token = io.prompt("API token", secret=True)
os.setenv("API_TOKEN", token)

Note: All io functions that can fail support try_ variants that return a Result instead of raising an error.