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.7.0.tar.gz
(5.4 kB
view details)
Built Distribution
File details
Details for the file cli-lite-0.7.0.tar.gz
.
File metadata
- Download URL: cli-lite-0.7.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.5.2 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57135b432fba714605850f4f199a1b3f154d64344ae0fcfb9df792220d9d9063 |
|
MD5 | e6406763e570144ba965f9d4fbbd7c07 |
|
BLAKE2b-256 | cc2dd092b1bdc4b6aeeb86d0b28817f4dd359b047d7011cba6859881dbf2063e |
File details
Details for the file cli_lite-0.7.0-py3-none-any.whl
.
File metadata
- Download URL: cli_lite-0.7.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.5.2 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 070a96b28bb952bdf0bbef07d8c414d6f9cb9f555356a63a5c8367c24e265119 |
|
MD5 | 609227e9e62e36195552bb796cb2ace1 |
|
BLAKE2b-256 | c5c977112886b4df410093d7fa1fd0891647edd111f82602f1762a79290c198a |