A dependency free prompts (not the LLM prompts) library built for CLI.
Project description
tinyprompts
A dependency-free interactive CLI prompts library for Python. Zero pip install dependencies -- just the stdlib.
tinyprompts does one job: collect user input interactively with a pretty TUI, then hand back a typed result. It does not replace argparse, click, or typer -- it complements them.
Note: The API may change before 1.0. Requires Python 3.9+ and a Unix TTY (macOS / Linux).
Dependency
None. Your only dependency is Python 3.9+.
Key Features
- Interactive prompts -- Text input (with regex validation), searchable multi-select, and yes/no confirmation, rendered in-terminal with keyboard navigation.
- Type-hint-first API -- Define prompts as a dataclass with
Annotatedfields. One dataclass, fully typed output. - Bring your own CLI -- tinyprompts returns a dataclass (or dict). Wire it into argparse, click, typer, or nothing at all.
- Tiny footprint -- 4 source files, ~500 lines total. Easy to vendor, audit, or fork.
- (Not implemented) - Defer preload. Python has a slow start problem which make it bad for CLI. Instead of fighting it, start the user interactive part first, and load the heavy things in the background.
Quickstart
from dataclasses import dataclass, field
from typing import Annotated
from tinyprompts import Text, Confirm, MultiSelect, Choice, prompt
@dataclass
class ProjectSetup:
name: Annotated[str, Text("Project name")] = "my-project"
tools: Annotated[list[str], MultiSelect("Pick tools", choices=[
Choice("ruff", "Linting"),
Choice("pytest", "Testing"),
])] = field(default_factory=list)
with_example: Annotated[bool, Confirm("Include example?")] = False
config = prompt(ProjectSetup) # interactive TUI, returns ProjectSetup or None
Pairing with argparse
tinyprompts doesn't own your CLI -- you do. Build your parser normally, then pass CLI values as defaults so prompt() only asks for what's missing:
import argparse
from tinyprompts import prompt
parser = argparse.ArgumentParser()
parser.add_argument("--name", default=None)
parser.add_argument("--tools", nargs="*", choices=["ruff", "pytest"])
args = parser.parse_args()
defaults = {k: v for k, v in vars(args).items() if v is not None}
config = prompt(ProjectSetup, defaults=defaults)
The same pattern works with click, typer, or any framework that produces a dict of values.
Install
pip install tinyprompts
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 tinyprompts-0.0.2.tar.gz.
File metadata
- Download URL: tinyprompts-0.0.2.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.12.3 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aae07052ac0eaf15d2188d515cd0858ae6f780a897911f329c1b866c65c4625a
|
|
| MD5 |
7bd95ad65cd0da52b2fbfeec64838cce
|
|
| BLAKE2b-256 |
1d55fdcf1863877d5611ccc6fdd803040dd5bc54320504f03c09fd4a64dd2b6a
|
File details
Details for the file tinyprompts-0.0.2-py3-none-any.whl.
File metadata
- Download URL: tinyprompts-0.0.2-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.12.3 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41b9de517e63ecc5a0599da457d7b4f5e929913df23cd987db649653f999ff31
|
|
| MD5 |
bb63ce40a6996a790627108888144fd2
|
|
| BLAKE2b-256 |
a47f8d0c1f6fcd258a0f5ae38be6e530fafed9d6bce7a5e8cc65ff41d696002b
|