click-plugins
click-plugins is an extension module for the Click library, designed to enable registering CLI commands via setuptools entry-points. The project's official PyPI package is currently marked as inactive, with version 1.1.1.2 being the final release. While a 2.0 release exists on GitHub, it restructured the project to support vendoring and no longer directly supports building a `pip` package, effectively making the PyPI offering abandoned.
Warnings
- breaking The PyPI package `click-plugins` is no longer actively maintained. Version 1.1.1.2 is the final release available via `pip install`.
- breaking GitHub release 2.0 is *not* a continuation of the PyPI package. It restructured the project for vendoring and explicitly states it 'no longer directly supports building a `pip` package'.
- gotcha Version 1.1 contained a mismatch between its stated version and `click_plugins.__version__`. It was superseded by 1.1.1.
- gotcha The primary mechanism for discovering commands relies on setuptools entry points. Misconfiguration of `setup.py` or `pyproject.toml` can lead to commands not being discovered.
Install
-
pip install click-plugins
Imports
- with_plugins
from click_plugins import with_plugins
Quickstart
import click
from click_plugins import with_plugins
import os
# Example of a 'plugin' that would be discovered via entry points
# In your setup.py/pyproject.toml, you'd define:
# [options.entry_points]
# click_commands = click_plugins_example.plugins:hello_plugin
@click.group()
def plugins():
"A group for plugin commands."
pass
@plugins.command()
def hello_plugin():
click.echo("Hello from a plugin!")
@with_plugins(ep_group='click_commands')
@click.group()
def cli():
"A CLI with plugin support."
pass
# To make the quickstart runnable without a full setup.py,
# we'll simulate the entry point discovery by directly adding it.
# In a real scenario, this wouldn't be necessary.
cli.add_command(plugins)
if __name__ == '__main__':
# In a real environment, you'd run `cli()` directly.
# For this quickstart, we're demonstrating the integration.
# For testing, ensure 'plugins' command is added.
cli()