Skip to main content

REPL extension to CLI apps

Project description

REPL on CLI

REPL extension to CLI apps

Example

import sys
from reploncli import reploncli

import my_cli_function, show_help

# turn on REPL mode if the first command line argument is 'repl'
lets_start_in_repl_mode = (sys.argv[1:] or [''])[0] == "repl"

reploncli(my_cli_function, lets_start_in_repl_mode, show_help, ">>> ")

reploncli()

Signature:

def reploncli(cli_function, repl_mode=None, help=None, prompt=""):
    ...

If repl_mode is True then REPL mode starts.

Wrap your CLI entry point

Create cli_function by wrapping your CLI entry point that accepts one optional argument with args to use as a replacement for sys.argv if given.
Otherwise process sys.argv as normal.

Shell commands

If an input in REPL mode starts with . then it's run by os.system() after removing that dot.

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

reploncli-0.9.4.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

reploncli-0.9.4-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file reploncli-0.9.4.tar.gz.

File metadata

  • Download URL: reploncli-0.9.4.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.10.6 Linux/5.15.0-52-generic

File hashes

Hashes for reploncli-0.9.4.tar.gz
Algorithm Hash digest
SHA256 606643cfdb1f1a13ef0894d2ff5cb7a8cf6d7a1a1c1af7e6774736b7fec3881c
MD5 aa0da2e3a07d9b0056beff857fa1fc8a
BLAKE2b-256 0c626ecc981bc6230ec0e0a70183d6b715c145d461dbb91a227e56b8a04dcba3

See more details on using hashes here.

File details

Details for the file reploncli-0.9.4-py3-none-any.whl.

File metadata

  • Download URL: reploncli-0.9.4-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.10.6 Linux/5.15.0-52-generic

File hashes

Hashes for reploncli-0.9.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ca7bfe13257bdb01baa26c178cf7226a9768805f7e9ca44eaa3f7f2639ede972
MD5 7c085803cfe4d50c654fcb35d1c46a4b
BLAKE2b-256 9473c54a6c6bea22711cf45dd520c48eefca56ac8013b62b3eb44eb583df8a40

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page