A simple framework to build a cli tool, base on Alconna
Project description
Cli-Lite
A simple framework to build a cli tool. Base on Alconna
install
pip install cli-lite
example
write as sample:
# example.py
from clilte import BasePlugin, CommandLine, PluginMetadata
from arclet.alconna import Alconna, Arparma, Args, CommandMeta
class MyPlugin(BasePlugin):
def init(self) -> Alconna | str:
return Alconna("hello", Args["name", str], meta=CommandMeta("test command"))
def meta(self) -> PluginMetadata:
return PluginMetadata("hello", "0.0.1", "my first plugin", ["dev"], ["john"])
def dispatch(self, result: Arparma) -> bool | None:
return print(f"Hello! {result.name}")
if __name__ == '__main__':
cli = CommandLine(title="My first CLI", version="example 0.0.1")
cli.add(MyPlugin)
cli.load_register('builtin.cache')
cli.main()
and execute the line:
python example.py hello world
you will get the result:
Hello! world
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-lite-0.8.3.tar.gz
(6.1 kB
view details)
Built Distribution
File details
Details for the file cli-lite-0.8.3.tar.gz
.
File metadata
- Download URL: cli-lite-0.8.3.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.11.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 197240086e1627cb77d599cf646efb74484e247edb715c8bea10f4bf19ed731c |
|
MD5 | 9c8d5c9bf8144aa5be99704586175632 |
|
BLAKE2b-256 | 66db5022441891484c8dec33d39340e4f69c4735a1158bf0ceed54824ee03ea8 |
File details
Details for the file cli_lite-0.8.3-py3-none-any.whl
.
File metadata
- Download URL: cli_lite-0.8.3-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.11.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59da8dcd8658a86799dae99a33842a27a093329ddc4673e7ac48e0cf4c1b0b40 |
|
MD5 | cd8f4eca8f7e80847e5d0777b2d01589 |
|
BLAKE2b-256 | 15c5fa45b725cada8b0d7c1cd30219245b1d6b80e2e7413b6b389c09a0d63079 |