Skip to main content

A flexible, interactive command-line prompt toolkit for Python.

Project description

CI codecov PyPI PyPI - Wheel PyPI - Python Version License security: bandit

Receptus

  RRRRR  EEEEE  CCCCC  EEEEE  PPPPP  TTTTT  U   U  SSSSS
  R   R  E      C      E      P   P    T    U   U  S
  RRRRR  EEEE   C      EEEE   PPPPP    T    U   U  SSSSS
  R R    E      C      E      P        T    U   U      S
  R  RR  EEEEE  CCCCC  EEEEE  P        T     UUU   SSSSS

Receptus — from the Latin "received (text)" — is a Python CLI prompt toolkit built for humans.

It enables the creation of intelligent and secure terminal interfaces with advanced input features like:

  • Option selection (single & multi)
  • Free-form text input
  • Input validation and transformation
  • Fuzzy matching and auto-complete
  • Password masking
  • ANSI and ASCII-compatible output
  • Timeout and retry handling
  • Input history
  • Event logging hooks (on_event)
  • Quit/help commands
  • Dynamic option lists

Installation

Receptus is a single-file drop-in module. Just copy receptus.py into your project.

You can also install it via PyPI or GitHub:

pip install receptus

pip install git+https://github.com/hustedev/receptus.git

Quick Start

from receptus import Receptus

prompt = Receptus()

color = prompt.get_input(
    prompt="Choose a color:",
    options={"r": "Red", "g": "Green", "b": "Blue"},
    default="g"
)

print(f"You chose: {color}")

Features

Prompt with Options

options = {
    "1": "Low",
    "2": "Medium",
    "3": "High"
}

choice = Receptus().get_input(
    prompt="Select difficulty:",
    options=options,
    default="2"
)

Free Text + Validation + Transform

def validate_port(s):
    try:
        port = int(s)
        return (0 < port < 65536, "Must be a valid port number")
    except:
        return (False, "Not a number")

def transform_port(s):
    return int(s)

port = Receptus().get_input(
    prompt="Enter port:",
    allow_free_text=True,
    validator=validate_port,
    transformer=transform_port
)

Multi-Select

files = Receptus().get_input(
    prompt="Select files:",
    options={"1": "fileA", "2": "fileB", "3": "fileC"},
    allow_multi=True,
    min_choices=1,
    max_choices=2
)

Fuzzy Match & Auto-Complete

name = Receptus().get_input(
    prompt="Enter country:",
    options={"us": "USA", "uk": "United Kingdom", "uae": "United Arab Emirates"},
    fuzzy_match=True,
    auto_complete=True
)

Password Masking + Timeout

secret = Receptus().get_input(
    prompt="Enter password:",
    mask_input=True,
    timeout_seconds=15
)

Event Logging via on_event

def logger(event_type, ctx):
    print(f"[{event_type}] -> {ctx}")

Receptus(on_event=logger).get_input(
    prompt="Choose something:",
    options={"1": "One", "2": "Two"},
)

Return Formats

You can control what get_input() returns:

return_format="key"     # (default) -> "1"
return_format="value"   # -> "One"
return_format="tuple"   # -> ("1", "One")

Environment Variables

  • FORCE_ASCII=1 — disables Unicode output
  • NO_COLOR=1 — disables ANSI color

License

MIT License — do anything you want, but attribution appreciated.

(c) 2025 James Husted — james@husted.dev


🚧 Roadmap

  • PyPI release
  • TypeScript wrapper for Node CLI tools
  • Native zsh/bash integration helpers
  • Dynamic theming

Contributing

Pull requests welcome! Just fork, branch, and submit.


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

receptus-0.1.5.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

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

receptus-0.1.5-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file receptus-0.1.5.tar.gz.

File metadata

  • Download URL: receptus-0.1.5.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for receptus-0.1.5.tar.gz
Algorithm Hash digest
SHA256 aea4d98d722252e1189ed53be5f25be68575a9a0f2449d2d181d9f5c74216caf
MD5 c0c227204188f4f67489f674a2d58178
BLAKE2b-256 c6b4f9a04e99c2d46eb20f822bcb604d1d466afbe188a31f47e624606ba22584

See more details on using hashes here.

Provenance

The following attestation bundles were made for receptus-0.1.5.tar.gz:

Publisher: publish.yml on HusteDev/receptus

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

File details

Details for the file receptus-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: receptus-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for receptus-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8f882c22ff7541d6aeece23250f349364045a3f95da833f5390edd3727cc5121
MD5 76093cd0a85b19052338e9f65ec9a795
BLAKE2b-256 d89c7b9732e3bab98e0bde7a8a314f506d5c8db5fef6805b077d612db10798b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for receptus-0.1.5-py3-none-any.whl:

Publisher: publish.yml on HusteDev/receptus

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