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, Option
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}")
@classmethod
def supply_options(cls) -> list[Option] | None:
return
if __name__ == '__main__':
cli = CommandLine(title="My first CLI", version="example 0.0.1")
cli.add(MyPlugin)
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.10.1.tar.gz
(6.5 kB
view details)
Built Distribution
File details
Details for the file cli_lite-0.10.1.tar.gz
.
File metadata
- Download URL: cli_lite-0.10.1.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.19.1 CPython/3.9.13 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bd1c320dec4b2132279a20a0cfaea719e79bbd26aad0ce261dda7c21a00016f |
|
MD5 | cc1157d2c0080010e04f158d79bda1ed |
|
BLAKE2b-256 | 7ccb2d09bd0cc78a1472d2fe7f745c1d0b0e21d5f1cf3a1a7abad4e3b3e9dbc7 |
File details
Details for the file cli_lite-0.10.1-py3-none-any.whl
.
File metadata
- Download URL: cli_lite-0.10.1-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.19.1 CPython/3.9.13 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d9d7e6f4f512e8e995d000e9d66a05458f2a34d0c49971fe209cbee483078a7 |
|
MD5 | bcf8a97cd6ef94a65ff965d243d81e11 |
|
BLAKE2b-256 | dd83688c98950cdd8b852aa23835cf3360236270c82b34d5355971bf961cf1ec |