Skip to main content

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:

  1. Console (CLI)
  2. GUI (Tkinter)
  3. 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 ConfigManager

# Custom path for a specific project
eds_config = ConfigManager("~/.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dworshak_prompt-0.2.15.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dworshak_prompt-0.2.15-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file dworshak_prompt-0.2.15.tar.gz.

File metadata

  • Download URL: dworshak_prompt-0.2.15.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

Hashes for dworshak_prompt-0.2.15.tar.gz
Algorithm Hash digest
SHA256 8fc8f192a2d67c60f7d10f6b80539816a3cee57715ee51a6f7d46c77260f3787
MD5 b07342df46879be1f1b6db42029c14aa
BLAKE2b-256 d06f2c90f338c1f0b41f72d8afbd228485046d97e1ca441138c0c3ec59078480

See more details on using hashes here.

Provenance

The following attestation bundles were made for dworshak_prompt-0.2.15.tar.gz:

Publisher: publish.yml on City-of-Memphis-Wastewater/dworshak-prompt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dworshak_prompt-0.2.15-py3-none-any.whl.

File metadata

File hashes

Hashes for dworshak_prompt-0.2.15-py3-none-any.whl
Algorithm Hash digest
SHA256 03a63ccec36e7f2b38733b6b124ab7d8ad0d9653e9d9a01d785fbd1e67ee6914
MD5 00abad16cc8d9ce4b49c1188a1b119ff
BLAKE2b-256 1dbf3bf4c5a91d947d16d154395767efa2028165a8a1653cd648c28bb1163ed4

See more details on using hashes here.

Provenance

The following attestation bundles were made for dworshak_prompt-0.2.15-py3-none-any.whl:

Publisher: publish.yml on City-of-Memphis-Wastewater/dworshak-prompt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page