Skip to main content

A set of utilities around click, for extensible CLI

Project description

extencli

A set of utilities around click, which offers extensible CLI mechanism, with little effort

Features

Easy third-party extensible click.group

This package offers a specialized click.group implementation. Using it, you can create a CLI that will be extended by simply installing additional modules.

As an example, here is how one would define an extensible click.group in their python package core_module:

import click

from extencli import PluginAutoloaderGroup

@click.group('core', cls=PluginAutoloaderGroup, depends_on='core_module')
def core_group():
    ...

The depends_on parameter is required:

  • depends_on specifies the name of the package that CLI extensions should depend on

Now, the CLI extension package should import the core_group from the core_module like so:

from core_module.cli import core_group

@core_group.command('myext')
def cli_extension():
    ...

Now, by simply installing both the core_module and the extension third-party, the core_module will be extended with the myext command:

$> core --help
Usage: core [OPTIONS] COMMAND [ARGS]...

Options:
  --help                          Show this message and exit.

Commands:
  myext

Caveats

Silent "failure" to load extensions

If the base CLI has its extensible group declared in the __init__.py file, the internal click initialization mechanism might use different instances of the group when loaded by extensions, and when invoked through the CLI.

To avoid this, please refer to the tests's tests/python_packages/test_core python module, which is built in a way that avoid this caveat:

  • extensible group should not be in the __init__.py file
  • pyproject.toml may refer directly to it for script entrypoints

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

extencli-0.2.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

extencli-0.2.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file extencli-0.2.0.tar.gz.

File metadata

  • Download URL: extencli-0.2.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for extencli-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d1ab05029eb5ef0c7eecbab75d7191ccc0bf2166317eaba3615cea000cd113ac
MD5 b040135ec705ec60855817e20d122e26
BLAKE2b-256 42bf9ff2524e0e0591e8f94684a10a527f729440acfc0a5417a7b5bb2e41ada1

See more details on using hashes here.

Provenance

The following attestation bundles were made for extencli-0.2.0.tar.gz:

Publisher: workflow.yml on Joacchim/extencli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file extencli-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: extencli-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for extencli-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c0fc35d09ec6eaf1fd6d6beb4d25d7d8ceab859070c6a441fb16a74068b06a0
MD5 587127c6d7405d8b463b74becebf00b3
BLAKE2b-256 d58710b42d43ded92fee3f52b688f55f2a67b93cf8204204662d3ef466935f51

See more details on using hashes here.

Provenance

The following attestation bundles were made for extencli-0.2.0-py3-none-any.whl:

Publisher: workflow.yml on Joacchim/extencli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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