Metadata-Version: 2.4
Name: larzprompt
Version: 0.1.0
Summary: Interactive, testable command-line prompts: text, confirm, select, integer, password, with validation and defaults. Pure Python, zero dependencies.
Author: larz-scripter
License: MIT
Project-URL: Homepage, https://github.com/larz-scripter/larzprompt
Project-URL: Repository, https://github.com/larz-scripter/larzprompt
Project-URL: Issues, https://github.com/larz-scripter/larzprompt/issues
Keywords: prompt,cli,interactive,input,confirm,select,menu,questions,testable,zero-dependency
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 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.

```python
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

```bash
pip install larzprompt
```

## Usage

```python
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

```bash
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](https://github.com/larz-scripter) - pairs with
[larzcli](https://github.com/larz-scripter/larzcli) and
[larzcolor](https://github.com/larz-scripter/larzcolor).

## License

MIT (c) larz-scripter
