click-plugins

1.1.1.2 · abandoned · verified Sat Mar 28

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

Install

Imports

Quickstart

This quickstart demonstrates how to use `with_plugins` to enable a Click group to discover commands via setuptools entry-points. The `ep_group` parameter specifies the entry-point group to look for. For this example to be fully functional, you would typically define entry points in your `setup.py` or `pyproject.toml` under a section like `[options.entry_points]`, e.g., `click_commands = my_package.my_plugins:my_command_function`.

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()

view raw JSON →