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.0.tar.gz
(6.5 kB
view details)
Built Distribution
File details
Details for the file cli_lite-0.10.0.tar.gz
.
File metadata
- Download URL: cli_lite-0.10.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.15.4 CPython/3.9.13 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85d0d78a60f3f7fb98d29313d44adcbc9136d96ad7479dbbfb626ece3748ba4e |
|
MD5 | 1224a1e4950c5dbe6e4d6280c65d306f |
|
BLAKE2b-256 | d1cf7c6d716480c9efd74c04fd676a4e92b007db7c8d9b517e67eba6373e2e86 |
File details
Details for the file cli_lite-0.10.0-py3-none-any.whl
.
File metadata
- Download URL: cli_lite-0.10.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.15.4 CPython/3.9.13 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9dccca181ec9a72ed8a68f2dd943bbe57c22041bb018badfd4a5952e4eae05ab |
|
MD5 | d546e42bbfb2ccbef9adf147f36bade3 |
|
BLAKE2b-256 | 580570360c50fba5dbb62274a8146f12fda2729cb3b03bee9cc5c879186b19a5 |