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¶
Confirmation with default¶
# Default to True — pressing Enter confirms
if io.confirm("Continue?", default=True):
print("Continuing...")
Text prompt¶
Prompt with default value¶
Secret input¶
Note: All
iofunctions that can fail supporttry_variants that return aResultinstead of raising an error.