This commit is contained in:
Iliyan Angelov
2025-09-14 23:24:25 +03:00
commit c67067a2a4
71311 changed files with 6800714 additions and 0 deletions

View File

@@ -0,0 +1,219 @@
Metadata-Version: 2.4
Name: click-plugins
Version: 1.1.1.2
Summary: An extension module for click to enable registering CLI commands via setuptools entry-points.
Home-page: https://github.com/click-contrib/click-plugins
Author: Kevin Wurster, Sean Gillies
Author-email: wursterk@gmail.com, sean.gillies@gmail.com
License: New BSD
Keywords: click plugin setuptools entry-point
Classifier: Topic :: Utilities
Classifier: Intended Audience :: Developers
Classifier: Development Status :: 7 - Inactive
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
License-File: LICENSE.txt
License-File: AUTHORS.txt
Requires-Dist: click>=4.0
Provides-Extra: dev
Requires-Dist: pytest>=3.6; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: wheel; extra == "dev"
Requires-Dist: coveralls; extra == "dev"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: summary
=============
click-plugins
=============
This PyPI package is no longer actively maintained, but the underlying
library can be vendored. See `homepage <https://github.com/click-contrib/click-plugins>`_
for more information.
An extension module for `click <https://github.com/pallets/click>`_ to register
external CLI commands via setuptools entry-points.
Why?
----
Lets say you develop a commandline interface and someone requests a new feature
that is absolutely related to your project but would have negative consequences
like additional dependencies, major refactoring, or maybe its just too domain
specific to be supported directly. Rather than developing a separate standalone
utility you could offer up a `setuptools entry point <https://pythonhosted.org/setuptools/setuptools.html#dynamic-discovery-of-services-and-plugins>`_
that allows others to use your commandline utility as a home for their related
sub-commands. You get to choose where these sub-commands or sub-groups CAN be
registered but the plugin developer gets to choose they ARE registered. You
could have all plugins register alongside the core commands, in a special
sub-group, across multiple sub-groups, or some combination.
Enabling Plugins
----------------
For a more detailed example see the `examples <https://github.com/click-contrib/click-plugins/tree/master/example>`_ section.
The only requirement is decorating ``click.group()`` with ``click_plugins.with_plugins()``
which handles attaching external commands and groups. In this case the core CLI developer
registers CLI plugins from ``core_package.cli_plugins``.
.. code-block:: python
from pkg_resources import iter_entry_points
import click
from click_plugins import with_plugins
@with_plugins(iter_entry_points('core_package.cli_plugins'))
@click.group()
def cli():
"""Commandline interface for yourpackage."""
@cli.command()
def subcommand():
"""Subcommand that does something."""
Developing Plugins
------------------
Plugin developers need to register their sub-commands or sub-groups to an
entry-point in their ``setup.py`` that is loaded by the core package.
.. code-block:: python
from setuptools import setup
setup(
name='yourscript',
version='0.1',
py_modules=['yourscript'],
install_requires=[
'click',
],
entry_points='''
[core_package.cli_plugins]
cool_subcommand=yourscript.cli:cool_subcommand
another_subcommand=yourscript.cli:another_subcommand
''',
)
Broken and Incompatible Plugins
-------------------------------
Any sub-command or sub-group that cannot be loaded is caught and converted to
a ``click_plugins.core.BrokenCommand()`` rather than just crashing the entire
CLI. The short-help is converted to a warning message like:
.. code-block:: console
Warning: could not load plugin. See ``<CLI> <command/group> --help``.
and if the sub-command or group is executed the entire traceback is printed.
Best Practices and Extra Credit
-------------------------------
Opening a CLI to plugins encourages other developers to independently extend
functionality independently but there is no guarantee these new features will
be "on brand". Plugin developers are almost certainly already using features
in the core package the CLI belongs to so defining commonly used arguments and
options in one place lets plugin developers reuse these flags to produce a more
cohesive CLI. If the CLI is simple maybe just define them at the top of
``yourpackage/cli.py`` or for more complex packages something like
``yourpackage/cli/options.py``. These common options need to be easy to find
and be well documented so that plugin developers know what variable to give to
their sub-command's function and what object they can expect to receive. Don't
forget to document non-obvious callbacks.
Keep in mind that plugin developers also have access to the parent group's
``ctx.obj``, which is very useful for passing things like verbosity levels or
config values around to sub-commands.
Here's some code that sub-commands could re-use:
.. code-block:: python
from multiprocessing import cpu_count
import click
jobs_opt = click.option(
'-j', '--jobs', metavar='CORES', type=click.IntRange(min=1, max=cpu_count()), default=1,
show_default=True, help="Process data across N cores."
)
Plugin developers can access this with:
.. code-block:: python
import click
import parent_cli_package.cli.options
@click.command()
@parent_cli_package.cli.options.jobs_opt
def subcommand(jobs):
"""I do something domain specific."""
Installation
------------
With ``pip``:
.. code-block:: console
$ pip install click-plugins
From source:
.. code-block:: console
$ git clone https://github.com/click-contrib/click-plugins.git
$ cd click-plugins
$ python setup.py install
Developing
----------
.. code-block:: console
$ git clone https://github.com/click-contrib/click-plugins.git
$ cd click-plugins
$ pip install -e .\[dev\]
$ pytest tests --cov click_plugins --cov-report term-missing
Changelog
---------
See ``CHANGES.txt``
Authors
-------
See ``AUTHORS.txt``
License
-------
See ``LICENSE.txt``

View File

@@ -0,0 +1,14 @@
__pycache__/click_plugins.cpython-312.pyc,,
click_plugins-1.1.1.2.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
click_plugins-1.1.1.2.dist-info/METADATA,sha256=yAp8lvQhJ3_U6dtzp0zfh181qntYtIRBLs-_Mn5KPGw,6461
click_plugins-1.1.1.2.dist-info/RECORD,,
click_plugins-1.1.1.2.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
click_plugins-1.1.1.2.dist-info/licenses/AUTHORS.txt,sha256=FUhD9wZxX5--d9KS7hUB-wnHgyS67pdnWvADk8lrLeE,90
click_plugins-1.1.1.2.dist-info/licenses/LICENSE.txt,sha256=-hmG0Gx9O6d2NSRgTbqzn69bGonHgSqNXZMufdcANtI,1517
click_plugins-1.1.1.2.dist-info/top_level.txt,sha256=oB_GDZcOeOKX1eKKCfqSMR4tfJS6iL3zJshaJJPSQUI,14
click_plugins-1.1.1.2.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
click_plugins.py,sha256=6E91i5df3URifE6VP0DA2iQKcvbTuHsEO6DeRr-QeFU,8095
click_plugins/__init__.py,sha256=BvL0vYsRX1ho7W5YCFmeEeiXwoiPa-EIcBvvWdezMoM,2249
click_plugins/__pycache__/__init__.cpython-312.pyc,,
click_plugins/__pycache__/core.cpython-312.pyc,,
click_plugins/core.py,sha256=4hhmUpFi6MSYsvxogksNu5dlKEWNscbiE9ynUy5dPdE,2475

View File

@@ -0,0 +1,6 @@
Wheel-Version: 1.0
Generator: setuptools (80.9.0)
Root-Is-Purelib: true
Tag: py2-none-any
Tag: py3-none-any

View File

@@ -0,0 +1,5 @@
Authors
=======
Kevin Wurster <wursterk@gmail.com>
Sean Gillies <sean.gillies@gmail.com>

View File

@@ -0,0 +1,29 @@
New BSD License
Copyright (c) 2015-2025, Kevin D. Wurster, Sean C. Gillies
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither click-plugins nor the names of its contributors may not be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1 @@
click_plugins