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.
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
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 DworshakConfig
# Custom path for a specific project
eds_config = DworshakConfig("~/.pipeline-eds/config.json")
api_key = eds_config.get("api_key", prompt_message="Enter EDS API Key")
The default config file path is "~/.dworshak/config.json".
Install as CLI (for demo purposes)
pipx install "dworshak-prompt[typer]"
dworshak-prompt --version
dworshak-prompt --help
dworshak-prompt ask --message "Please state name" --mode web
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_prompt functionality are still stable, due to Python standard library fallbacks.
More Information
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.18.tar.gz.
File metadata
- Download URL: dworshak_prompt-0.2.18.tar.gz
- Upload date:
- Size: 20.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 |
27a03a33ca24b90f4702af04f4538b3b2d14fda0c4c38a5e6259ca2bb3b4aaf0
|
|
| MD5 |
5783deeda7bcd0cc012cf45727e5a3c8
|
|
| BLAKE2b-256 |
14c899e875d8fa1b45cccf0b6570f723cbd9fe075d31342e09adcc889ab65536
|
Provenance
The following attestation bundles were made for dworshak_prompt-0.2.18.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.18.tar.gz -
Subject digest:
27a03a33ca24b90f4702af04f4538b3b2d14fda0c4c38a5e6259ca2bb3b4aaf0 - Sigstore transparency entry: 951946365
- Sigstore integration time:
-
Permalink:
City-of-Memphis-Wastewater/dworshak-prompt@53f443cdb16d2f77d0d43c180afbd78e05a77a08 -
Branch / Tag:
refs/tags/v0.2.18 - 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@53f443cdb16d2f77d0d43c180afbd78e05a77a08 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dworshak_prompt-0.2.18-py3-none-any.whl.
File metadata
- Download URL: dworshak_prompt-0.2.18-py3-none-any.whl
- Upload date:
- Size: 25.3 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 |
6b4a846880ca503958cdb8ad9e068aaf2dec5db73b8394c8379b5301126d5542
|
|
| MD5 |
07fb5f090db95cbf9a77f63fe92c6a92
|
|
| BLAKE2b-256 |
4587b8fa22b39eb049be019265db0f7190f484b70e0db246d24ea2f83957df8a
|
Provenance
The following attestation bundles were made for dworshak_prompt-0.2.18-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.18-py3-none-any.whl -
Subject digest:
6b4a846880ca503958cdb8ad9e068aaf2dec5db73b8394c8379b5301126d5542 - Sigstore transparency entry: 951946393
- Sigstore integration time:
-
Permalink:
City-of-Memphis-Wastewater/dworshak-prompt@53f443cdb16d2f77d0d43c180afbd78e05a77a08 -
Branch / Tag:
refs/tags/v0.2.18 - 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@53f443cdb16d2f77d0d43c180afbd78e05a77a08 -
Trigger Event:
release
-
Statement type: