Skip to main content

larzprompt

Interactive, testable command-line prompts. Pure Python, zero dependencies.

Ask the user questions and get validated answers, with defaults, re-prompting on bad input, and a numbered menu for choices. Everything takes an injectable input function and output stream, so prompts are unit-testable - which most prompt libraries make painful.

from larzprompt import text, confirm, select, integer

name  = text("Your name?", default="Anon")
if confirm("Continue?", default=True):
    color = select("Pick a color", ["red", "green", "blue"])
    age   = integer("Age?", min=0, max=150)

Why

  • Testable prompts. Every function takes input_fn and output (and password takes getpass_fn), so you feed canned answers and capture output in a test - no subprocess, no pty. This repo's 15 tests do exactly that.
  • The prompts you need. text (default + validate), confirm (y/n + default), select (numbered menu, plain values or (label, value) pairs), integer (parse + min/max), and password (no echo).
  • Forgiving. Invalid input re-prompts with a helpful message instead of crashing.
  • Zero dependencies. No inquirer, no questionary, no prompt_toolkit.

Install

pip install larzprompt

Usage

from larzprompt import text, confirm, select, integer, password

text("Email?", validate=lambda s: None if "@" in s else "must contain @")
confirm("Delete everything?", default=False)
select("Environment", [("Production", "prod"), ("Staging", "stage")])
integer("Port", default=8080, min=1, max=65535)
password("Enter password")

Tests

python -m unittest discover -s tests -v   # 15 tests (canned answers + captured output)

The Larz stack

One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter - pairs with larzcli and larzcolor.

License

MIT (c) larz-scripter

Metadata

Release files for larzprompt 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for larzprompt 0.1.0
File Size Uploaded Provenance
larzprompt-0.1.0.tar.gz 5.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for larzprompt 0.1.0
File Interpreter ABI Platform
larzprompt-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.5 kB

Release files / larzprompt-0.1.0.tar.gz

Download URL larzprompt-0.1.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
eb311cbe03095510e45952b2d538aee00a9d4dfde1ff3ee48fd3641d51c6730b
BLAKE2b-256 checksum
How to use checksums
cf0ca9704806a862d60c28cce940a9d4a5b53bcc3aee9ed7fab668246f4f3f89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / larzprompt-0.1.0-py3-none-any.whl

Download URL larzprompt-0.1.0-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e0211aa83444a622df1e21134843246a1b795560bf3badda5ec7a2cace24a16d
BLAKE2b-256 checksum
How to use checksums
53ef5630403c4149b6f769f02bef201d2c8ce35f727985232b6736d0bfc81de1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for larzprompt 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page