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, andexitcommands - 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
loggingmodule fromcli-ihto use the same config as the module - You can provide the
thread_modeparam to theInputHandlerclass to set if it shoud run in a thread or no. (If you are using thecli-ihmodule on its own without any other background task setthread_mode=Falseto false) - You can also provide a
cursorparam to theInputHandlerclass to set the cli cursor (default cusor is empty)
Project details
Release history Release notifications | RSS feed
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.3.3.tar.gz
(3.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cli_ih-0.5.3.3.tar.gz.
File metadata
- Download URL: cli_ih-0.5.3.3.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2e2b50aed6dd134a2b1ab23956a72f4b91611a8dc02e2149eacd4498ad20da0
|
|
| MD5 |
3cb9d7bfbcf395bd02ea53ffdea30fc3
|
|
| BLAKE2b-256 |
24ea252f3617b1beca9cae6d1405f55a14d767d5a94576deb5c540a82fedd5ad
|
File details
Details for the file cli_ih-0.5.3.3-py3-none-any.whl.
File metadata
- Download URL: cli_ih-0.5.3.3-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d41caef8f1f16b84f2d3c2d35abb3a5d90c20204b13341a23662c75b689668a
|
|
| MD5 |
6fb9552e08adb12d67cc3c5cdb068220
|
|
| BLAKE2b-256 |
4dc17711ce674b1cf18942fa23636eed45c7f4fba10c58a0f2530c0ae23fea44
|