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.1.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file cli-lite-0.8.1.tar.gz
.
File metadata
- Download URL: cli-lite-0.8.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.10.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b3e9789c87b4793e7b9e80aec6360e493a790e0f11c337bdbdcec8eaa02f66b |
|
MD5 | a9782de1e82b2be368a67ab75f43b7d5 |
|
BLAKE2b-256 | c26dad93d6d72a6123c0064e0cca9032abb7d160c1a369d2a0152d44bdb38b2b |
File details
Details for the file cli_lite-0.8.1-py3-none-any.whl
.
File metadata
- Download URL: cli_lite-0.8.1-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.10.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66473d77ed0ca77a70ded1e35c38ab36c65b3c7b3ce3b23814aef682dacf1c2c |
|
MD5 | c35eed09c5e98d7fd289e924a2dea193 |
|
BLAKE2b-256 | 09b650188d5641ad74328de6c4d614f98622db1b03c498f1977b32f7ec4eebc1 |