Skip to main content

Read–Eval–Print Loop Interpreter

Project description

🐟 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

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

repli-0.2.7.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

repli-0.2.7-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file repli-0.2.7.tar.gz.

File metadata

  • Download URL: repli-0.2.7.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for repli-0.2.7.tar.gz
Algorithm Hash digest
SHA256 40cc36c60caad330c3d9ff413a1d0361b498cf5b546dda46792130223f62d3f8
MD5 f4c564d4826c448cd32c31b02c1c7b48
BLAKE2b-256 08c8fdd170bc709ecdf8aa4c4c972988303f29cd0c483b4265441a02bcb9cbd0

See more details on using hashes here.

File details

Details for the file repli-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: repli-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for repli-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 81e66be40105839bc9ccb68513259e8d06ed7f4779b3e2c7ba41f4c070a07613
MD5 8436d5d5063f8f77f3bb29b96c8cab20
BLAKE2b-256 ba8d7a4e92a9ff9b7df4f67b79b0e0bef568b05ccdb8eeaab07c21f0a6ff7f8f

See more details on using hashes here.

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