Skip to main content

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


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.8.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

cli_lite-0.8.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file cli-lite-0.8.0.tar.gz.

File metadata

  • Download URL: cli-lite-0.8.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.10.1 CPython/3.9.13

File hashes

Hashes for cli-lite-0.8.0.tar.gz
Algorithm Hash digest
SHA256 3a9b7e3c42b0ead25f281ef2c7748ee52900886239c6d021b75d7e9d3cfca38e
MD5 cfee45840443fa142ce59a7c1460b623
BLAKE2b-256 e92720960f0362ecdcc08161c22cda3db57e682ee92d5900d255970a883fd4e0

See more details on using hashes here.

File details

Details for the file cli_lite-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: cli_lite-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.10.1 CPython/3.9.13

File hashes

Hashes for cli_lite-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f733f807b7a6f3ef91034d2f34b226e0ee90dd3cf946dd9b95aa40ade64f050
MD5 e834bb1921d707a4bc8c252a85fe321f
BLAKE2b-256 afda22e96fe1be79e8c12fe8a57fae6c65b7c7073e6028c4f2f6789e0de8359c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page