https://github.com/rf-tar-railt/cli-lite
A simple frameworl to build a commandline tool
https://github.com/rf-tar-railt/cli-lite
alconna cli-tool commandline-tool python
Last synced: 2 months ago
JSON representation
A simple frameworl to build a commandline tool
- Host: GitHub
- URL: https://github.com/rf-tar-railt/cli-lite
- Owner: RF-Tar-Railt
- License: mit
- Created: 2022-07-11T15:56:40.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-11-06T08:47:20.000Z (7 months ago)
- Last Synced: 2025-03-06T10:06:18.053Z (3 months ago)
- Topics: alconna, cli-tool, commandline-tool, python
- Language: Python
- Homepage:
- Size: 85 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cli-Lite
A simple framework to build a cli tool. Base on [`Alconna`](https://github.com/ArcletProject/Alconna)
## install
```shell
pip install cli-lite
```## example
write as sample:
```python
# example.py
from clilte import BasePlugin, CommandLine, PluginMetadata
from arclet.alconna import Alconna, Arparma, Args, CommandMeta, Optionclass 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:
returnif __name__ == '__main__':
cli = CommandLine(title="My first CLI", version="example 0.0.1")
cli.add(MyPlugin)
cli.main()
```and execute the line:
```shell
python example.py hello world
```you will get the result:
```shell
Hello! world
```