Skip to main content

A background command handler for python's command line interface.

Project description

InputHandler Library

A lightweight Python library for creating interactive command-line interfaces with custom command registration and input handling. It supports threaded input processing and includes enhanced logging with color-coded output.

Features

  • Command registration system with descriptions
  • Threaded or non-threaded input handling
  • Colored logging with support for debug mode
  • Built-in help, debug, and exit commands
  • Error handling for missing or invalid command arguments

Installation

pip install cli-ih

Quick Start

from cli_ih import InputHandler

def greet(args):
    print(f"Hello, {' '.join(args)}!")

handler = InputHandler()
handler.register_command("greet", greet, "Greets the user. Usage: greet [name]")
handler.start()

# Now type commands like:
# > greet world
# > help
# > debug
# > exit

Additional Info

  • You can also import the logging module from cli-ih to use the same config as the module
  • You can provide the thread_mode param to the InputHandler class to set if it shoud run in a thread or no. (If you are using the cli-ih module on its own without any other background task set thread_mode=False to false)
  • You can also provide a cursor param to the InputHandler class to set the cli cursor (default cusor is empty)

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

cli_ih-0.5.2.2.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

cli_ih-0.5.2.2-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file cli_ih-0.5.2.2.tar.gz.

File metadata

  • Download URL: cli_ih-0.5.2.2.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for cli_ih-0.5.2.2.tar.gz
Algorithm Hash digest
SHA256 c6cd16f657e6c4137ae1270dcacce4ea38552a1481c3a783a1b97c3ce02dc89f
MD5 981f19d297ff0920573d77b2a4e39b37
BLAKE2b-256 649ecec6c7e8c246aae2d51d362f202fb26f1e508c489f91b21255b09a407875

See more details on using hashes here.

File details

Details for the file cli_ih-0.5.2.2-py3-none-any.whl.

File metadata

  • Download URL: cli_ih-0.5.2.2-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for cli_ih-0.5.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f5cbf5df913a582ead5ac9f395c35bea7c4ba2fc5da4539b873e97cc473c7f14
MD5 ea97b6800dc6838614a5e30b77093384
BLAKE2b-256 7d0c8f9c9963c5c156709352fa720811d398b95c7db22be201f1f98b274a2c58

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