🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

repli

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

repli

Read–Eval–Print Loop Interpreter

0.2.7
PyPI
Maintainers
1

🐟 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

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts