Python library for CLIs that use interactive prompts, subprocess runs with Rich output, and test helpers so the same flows run in tests without a TTY.
- Install:
uv add ask-shellorpip install ask-shell(Python 3.13+) - Docs: GitHub Pages
- ask: Prompts (confirm, text, select list/dict, single and multiple choice) built on questionary, with Rich styling
- shell: Run shell commands via
run,run_and_wait, andrun_pool; prefixed live output, optional log dirs, retries, and interrupt handling - console: Rich console and progress utilities;
configure_logging(app)wires a Typer app to Rich logging (handler, command decorator, optional secret hiding) - shell_events: Callbacks for run lifecycle (before/after, stdout/stderr) for custom handling
- AskShellSettings: Paths and options (e.g. run log directory); plug into your config or env
from ask_shell import ask, shell
if ask.confirm("Run the script?", default=True):
name = ask.text("Name:", default="world")
shell.run_and_wait(f"echo Hello, {name}")Use question_patcher to feed fixed responses to prompts, or raise_on_question to fail fast when a prompt is hit. Both are context managers; see the ask API docs for details.
from ask_shell import ask
from ask_shell.ask import question_patcher
with question_patcher(responses=["y", "myname"]):
assert ask.confirm("Run?")
assert ask.text("Name:") == "myname"MIT. See LICENSE.