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.2.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file cli-lite-0.8.2.tar.gz
.
File metadata
- Download URL: cli-lite-0.8.2.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 | 8a4490182e2bc360fb1d67f4b1d1689781508fb185131070dd575be0346229a8 |
|
MD5 | d9c4268301dad99002cb1872a96d1596 |
|
BLAKE2b-256 | 39ed0685cc7f1d7c2fc4077c913992c758dacb259188b87836295038a0a74394 |
File details
Details for the file cli_lite-0.8.2-py3-none-any.whl
.
File metadata
- Download URL: cli_lite-0.8.2-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 | 89066cee38e67de255ab0beb338647d68bd6fb6152f66873ac195212c669b1b5 |
|
MD5 | 4dfd8b757c91149f88f79adbe6524fce |
|
BLAKE2b-256 | 4778a9f7e6fb73c655ce46031cd91bb77c5b5f72076ba929ea5be9efba93ba0e |