Skip to main content

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

Project description

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 GitHub (PyPI coming soon):

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.4.tar.gz (11.6 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.4-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for receptus-0.1.4.tar.gz
Algorithm Hash digest
SHA256 41688c0d9517118a6ff0344a9b61ebc2a4c92dfe82c1dfa5c2dba9ba4cc2190a
MD5 c10c958a7a9926fc65ccef9a5bc7a90e
BLAKE2b-256 3d506f793e58b7b5999824f1dca974aa55ad147305b9e4f55b1f4f09f58f05d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for receptus-0.1.4.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.4-py3-none-any.whl.

File metadata

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

File hashes

Hashes for receptus-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7197f477016379580215ba705d46669ac47e55a138919f9c7b3579d6f19228e6
MD5 81efff741078e5eb2593c24c60d3b436
BLAKE2b-256 272a0a4720b5ac50fd38c5e33291679e31e79e930fe7e396fa823747b42b8481

See more details on using hashes here.

Provenance

The following attestation bundles were made for receptus-0.1.4-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