CLIs with prompts, shell runs, and testable flows
Project description
ask-shell
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
What it provides
- 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
Quick example
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}")
Testing
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"
License
MIT. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ask_shell-0.4.0.tar.gz.
File metadata
- Download URL: ask_shell-0.4.0.tar.gz
- Upload date:
- Size: 30.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e1b58cbb61016f156d08baece71b8161f8ec7cf96171dcc816f7cbbda57eb97
|
|
| MD5 |
520a96a6aff18abadd98989c94e55e28
|
|
| BLAKE2b-256 |
23acf760fb4054ef72ca4f5f46ec6128e1997d69e5375353cf8d1a8d1238d215
|
Provenance
The following attestation bundles were made for ask_shell-0.4.0.tar.gz:
Publisher:
release.yaml on EspenAlbert/ask-shell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ask_shell-0.4.0.tar.gz -
Subject digest:
1e1b58cbb61016f156d08baece71b8161f8ec7cf96171dcc816f7cbbda57eb97 - Sigstore transparency entry: 991402170
- Sigstore integration time:
-
Permalink:
EspenAlbert/ask-shell@99b2521f07299e30e6f4ef412792dfed87b386ee -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/EspenAlbert
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@99b2521f07299e30e6f4ef412792dfed87b386ee -
Trigger Event:
push
-
Statement type:
File details
Details for the file ask_shell-0.4.0-py3-none-any.whl.
File metadata
- Download URL: ask_shell-0.4.0-py3-none-any.whl
- Upload date:
- Size: 37.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3a057690f5c64b87591b168fe45c78cdc821e01e17503a6a3086d4e8980424b
|
|
| MD5 |
e50e5d930fdaed9d018c0d1c3ea24439
|
|
| BLAKE2b-256 |
63fb506c327cd330bbb67bfcc96654b9a9f8d431c3ba5ac43984ec5a38d452f6
|
Provenance
The following attestation bundles were made for ask_shell-0.4.0-py3-none-any.whl:
Publisher:
release.yaml on EspenAlbert/ask-shell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ask_shell-0.4.0-py3-none-any.whl -
Subject digest:
e3a057690f5c64b87591b168fe45c78cdc821e01e17503a6a3086d4e8980424b - Sigstore transparency entry: 991402174
- Sigstore integration time:
-
Permalink:
EspenAlbert/ask-shell@99b2521f07299e30e6f4ef412792dfed87b386ee -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/EspenAlbert
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@99b2521f07299e30e6f4ef412792dfed87b386ee -
Trigger Event:
push
-
Statement type: