Multiplexed user input via console, GUI, and web, depending on availability.
Project description
dworshak-prompt
A Python utility that ensures you can always get user input by falling back through multiple interfaces.
dworshak-prompt is a CI-safe, shell-friendly prompting engine that integrates with persistent config and secret storage.
How it works
It captures input by cycling through modes based on environment availability:
- Console (CLI)
- GUI (Tkinter)
- Web (Local Browser Server)
Automatically skips incompatible modes (e.g., GUI on WSL) via pyhabitat.
Usage
Obtain
Leverage dworshak-config, dworshak-config, and dworshak-env to automatically handle values.
from dworshak_prompt import Obtain
obtain = Obtain()
obtain.config(service, item, message)
obtain.secret(service, item, message)
obtain.env(key, message)
Ask
Prompt the user then handle values manually.
from dworshak_prompt import DworshakPrompt, PromptMode
# Basic
val = DworshakPrompt().ask("Enter value")
# Options
val = DworshakPrompt().ask(
message = "Secure Key",
hide_input=True,
priority = [PromptMode.CONSOLE, PromptMode.GUI]
avoid = {PromptMode.WEB}
)
Another example, for handling CI:
from dworshak_prompt import DworshakPrompt, PromptMode
# If this runs in GitHub Actions, it returns "staging" immediately.
# If it runs on a laptop, it pops up a GUI or Console prompt.
val = DworshakPrompt().ask(
message = "Target Environment",
suggestion="production", # What the human sees
default="staging" # What the CI/Headless system uses
)
Leveraging dworshak-prompt for calling and adding configured values.
from dworshak_prompt import Obtain
# Custom path for a specific project
obtain_mgr = Obtain(config_path="~/.pipeline-eds/config.json")
api_key = obtain_mgr.config("api_key", message="Enter EDS API Key")
The default config file path is "~/.dworshak/config.json".
CLI
The dworshak layer is the intended primary CLI entry point, but the dworshak-prompt CLI can be used directly.
pipx install "dworshak-prompt[typer]"
dworshak-prompt --version
dworshak-prompt --help
dworshak-prompt ask --message "Please state name" --interace web
dworshak-prompt is designed to be useful even without Python code.
It can be used directly from shell scripts, CI pipelines, and ops tooling to safely obtain, persist, and reuse configuration values.
Piping and environment variable capture works, but will naturally fallback to GUI or Web input because in these cases stdout is not a TTY. However, you may continue to use console input and leverage dev/tty by using envionrmental variable DWORSHAK_FORCE_INTERACTIVE_TTY.
# Enable console input during wrapped or piped shell capture.
export DWORSHAK_FORCE_INTERACTIVE_TTY=1
VAR=$(dworshak-prompt obtain secret "special_api" "password" --emit)
See the dworshak-prompt Typer CLI structure.
dworshak-prompt helptree
helptree is utility funtion for Typer CLIs, imported from the typer-helptree library.
- GitHub: https://github.com/City-of-Memphis-Wastewater/typer-helptree
- PyPI: https://pypi.org/project/typer-helptree/
Add dworshak-prompt to Python project
When using uv for dependency management.
uv add dworshak-prompt --extra typer
Or, when using raw pip for dependency management.
pip install "dworshak-prompt[typer]"
Including the typer optional dependency group ensures that Typer and Rich are included as a dependencies.
Without this, the CLI and console prompting functionality are still stable, due to Python standard library fallbacks.
More Information
Sister Projects in the Dworshak Ecosystem
- CLI/Orchestrator: dworshak
- Interactive UI: dworshak-prompt
- Secrets Storage: dworshak-secret
- Plaintext Pathed Configs: dworshak-config
- Classic .env Injection: dworshak-env
pipx install dworshak
pip install dworshak-secret
pip install dworshak-config
pip install dworshak-env
pip install dworshak-prompt
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 dworshak_prompt-0.2.29.tar.gz.
File metadata
- Download URL: dworshak_prompt-0.2.29.tar.gz
- Upload date:
- Size: 30.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4144f4f06e988794d1e2844f8da1d5425d0e9eebba824eaae5456b7df1605886
|
|
| MD5 |
73e83352cb3289a2df7dc9d40398fb16
|
|
| BLAKE2b-256 |
a4c32d59ce46f9d746e47226a646341a06ea451f7e742c92abeb4c8844da3d85
|
Provenance
The following attestation bundles were made for dworshak_prompt-0.2.29.tar.gz:
Publisher:
publish.yml on City-of-Memphis-Wastewater/dworshak-prompt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dworshak_prompt-0.2.29.tar.gz -
Subject digest:
4144f4f06e988794d1e2844f8da1d5425d0e9eebba824eaae5456b7df1605886 - Sigstore transparency entry: 1106487671
- Sigstore integration time:
-
Permalink:
City-of-Memphis-Wastewater/dworshak-prompt@85ae216b0532b61fe055508e52ea87c1b6d9391f -
Branch / Tag:
refs/tags/v0.2.29 - Owner: https://github.com/City-of-Memphis-Wastewater
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@85ae216b0532b61fe055508e52ea87c1b6d9391f -
Trigger Event:
release
-
Statement type:
File details
Details for the file dworshak_prompt-0.2.29-py3-none-any.whl.
File metadata
- Download URL: dworshak_prompt-0.2.29-py3-none-any.whl
- Upload date:
- Size: 34.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 |
266ff01897bce3e69842b11b79987d6175052a424cd51ee1bb0c85d43310f5df
|
|
| MD5 |
8dcf10137bfd923a8f713ce1a6c6c2db
|
|
| BLAKE2b-256 |
61f0014ef163fd9bf9c6491eedf9f3933a5c935e3f99087515ab5e28f2df7590
|
Provenance
The following attestation bundles were made for dworshak_prompt-0.2.29-py3-none-any.whl:
Publisher:
publish.yml on City-of-Memphis-Wastewater/dworshak-prompt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dworshak_prompt-0.2.29-py3-none-any.whl -
Subject digest:
266ff01897bce3e69842b11b79987d6175052a424cd51ee1bb0c85d43310f5df - Sigstore transparency entry: 1106487748
- Sigstore integration time:
-
Permalink:
City-of-Memphis-Wastewater/dworshak-prompt@85ae216b0532b61fe055508e52ea87c1b6d9391f -
Branch / Tag:
refs/tags/v0.2.29 - Owner: https://github.com/City-of-Memphis-Wastewater
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@85ae216b0532b61fe055508e52ea87c1b6d9391f -
Trigger Event:
release
-
Statement type: