🐟 Read–Eval–Print Loop Interpreter (REPLI)
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
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:
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)
| File | Size | Uploaded | |
|---|---|---|---|
| repli-0.2.7.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|