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.2.tar.gz
(6.6 kB
view details)
Built Distribution
File details
Details for the file cli_lite-0.10.2.tar.gz
.
File metadata
- Download URL: cli_lite-0.10.2.tar.gz
- Upload date:
- Size: 6.6 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 | 2cb62cfa89c0eddf81328253fbe6994d7e57bb2aea91d10ceb378a61e03753d3 |
|
MD5 | 1ddac791d45cebc215aab1aacc7699b7 |
|
BLAKE2b-256 | c107f3a7f0724d364c04e735a58618c2728f974285fb13cb728686acfef7481e |
Provenance
File details
Details for the file cli_lite-0.10.2-py3-none-any.whl
.
File metadata
- Download URL: cli_lite-0.10.2-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 | a4835512d13c82bd596c7dd343c0dcdfd7c18226d8092c05ae6726f3539b0887 |
|
MD5 | 99342f911ffc8a61583ecb09a08373e6 |
|
BLAKE2b-256 | ad3fd59f76caa4ffd71731360887c69ab572a4b5233e996ccfc4420bb8dfb5fa |