Skip to main content

Asynchronous CLI framework with command routing and advanced prompt features.

Project description

Simple CLI

Asynchronous framework in which you can create interactive command line interfaces with:

  • Dynamic completion
  • Color schemes
  • Customizable prompts

Quick start

Installation

pip install simple-cli-otus

Basic usage

from SimpleCLI import CommandLineInterface, CommandLineInterfaceConfig
import asyncio

config = CommandLineInterfaceConfig(
    PROMPT_FORMAT_STRING=">>> ",
    TRANSIENT_PROMPT=True,
    SUGGESTION_COLORS="green"
)

cli = CommandLineInterface(config)

@cli.command()
async def hello(name: str = "world"):
    """User greeting."""
    print(f"Hello, {name}!")

@cli.command(arg_spec={
    'status': {
        'flags': ['-s', '--status'],
        'help': "Some status.",
        'action': 'store_true'
    }
})
async def check(status: bool = False):
    """System checkup"""
    if status:
        print("System: OK")
    else:
        print("No status provided")

# Running interface
async def main():
    await cli.start()
    await cli.stop()
if __name__ == "__main__":
    asyncio.run(main())

Features

  • ANSI color schemes
  • Autosuggestion by Tab
  • Asynchronous operations
  • Configuration via Pydantic-model

Restrictions

Some configuration features are not implemented yet:

  • User role model
  • Output routing
  • Command conveyors
  • Log filtering

Development

Clone repository and install in development mode:

git clone https://github.com/MartisCoding/SimpleCLI
cd SimpleCLI
pip install -e .[dev]

License

This project was developed under MIT Licence.

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

simple_cli_otus-0.0.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

simple_cli_otus-0.0.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file simple_cli_otus-0.0.0.tar.gz.

File metadata

  • Download URL: simple_cli_otus-0.0.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for simple_cli_otus-0.0.0.tar.gz
Algorithm Hash digest
SHA256 154e6d0474192dbf6267a335875a805d02c241cf1e4a4ab2eb8d53a435f83331
MD5 2a2579b15245671f6b4ebe63344685b0
BLAKE2b-256 00f04e11e87282021b7437bcd423fb38fed01175077282479a1908dc4f125be3

See more details on using hashes here.

File details

Details for the file simple_cli_otus-0.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_cli_otus-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aedca37b8ef0230fabdce65ce0e2d051f885e033dcea80f0debc6a083521df62
MD5 684e27427c242812f23af325cbc93c58
BLAKE2b-256 1469b8e6be745fa25695aa8adfc140dfd0d7e438ed948ffd0282d9698c266cfc

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