Skip to main content

🐟 Read–Eval–Print Loop Interpreter (REPLI)

repli package publish license python pypi

It's a Python package for building command-line terminal applications.

Don't save frequently used commands in NotePad. Don't alias a lot of complex commands. Build a Read–Eval–Print Loop (REPL) style terminal application containing pre-defined commands for easy executions from terminal.

Preview of the example application in terminal:

┌──────────────────────────────────────────────────────────────┐
│ [myapp] home                                                 │
├──────────────────────────────────────────────────────────────┤
│                                                              │
│ 1  print hello world                                         │
│ 2  do something                                              │
│ 3  nested page                                               │
│                                                              │
├──────────────────────────────────────────────────────────────┤
│ e  exit application  |  q  quit page                         │
└──────────────────────────────────────────────────────────────┘
> 

Features

  • Command: A command is a pre-defined executable which can be one of the following:
    • Python native function
    • Shell command (subprocess)
  • Page: A page contains multiple commands or nested pages.
  • User interface:
    • Header: The header contains breadcrumbs for page navigation.
    • Panel: The panel contains the commands or pages for the current page.
    • Footer: The footer contains built-in control commands.
  • Input: Given the commands or pages with their unique names (in the first column) in the panel, type the name and enter to execute the command or navigate to the page.

Install

pip install repli

Usage

Example:

page = Page(description="home")

@page.command(type=NativeFunction, description="print hello world")
def command_print_hello_world():
    print("hello world")

@page.command(type=Subprocess, description="do something")
def command_do_something():
    return "echo something else"

nested_page = Page(description="nested page")
page.add_page(page=nested_page)

interpreter = Interpreter(page=page, name="myapp")
interpreter.loop()

Development

Requirements:

Poetry

Setup environment:

poetry shell
poetry install

Run example application:

poetry run example

Type check:

poetry run mypy ./example ./repli ./tests

Format:

poetry run black ./example ./repli ./tests

Lint:

poetry run flake8 ./example ./repli ./tests --config ./.flake8

Test:

poetry run pytest

Coverage:

poetry run coverage run -m pytest &&
poetry run coverage report -m

Export requirements.txt:

poetry export --dev --without-hashes --format=requirements.txt > requirements.txt

Release files for repli 0.2.7

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

Source distribution (sdist)

Source distribution for repli 0.2.7
File Size Uploaded
repli-0.2.7.tar.gz 8.3 kB Details

Built distribution (wheel)

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

Total release size: 18.5 kB

Release files / repli-0.2.7.tar.gz

Download URL repli-0.2.7.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
40cc36c60caad330c3d9ff413a1d0361b498cf5b546dda46792130223f62d3f8
BLAKE2b-256 checksum
How to use checksums
08c8fdd170bc709ecdf8aa4c4c972988303f29cd0c483b4265441a02bcb9cbd0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release files / repli-0.2.7-py3-none-any.whl

Download URL repli-0.2.7-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
81e66be40105839bc9ccb68513259e8d06ed7f4779b3e2c7ba41f4c070a07613
BLAKE2b-256 checksum
How to use checksums
ba8d7a4e92a9ff9b7df4f67b79b0e0bef568b05ccdb8eeaab07c21f0a6ff7f8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release history Release notifications | RSS feed

This release

0.2.7 This release

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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