Page MenuHomeSoftware Heritage

D3930.id.diff
No OneTemporary

D3930.id.diff

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -67,8 +67,7 @@
swh=swh.core.cli:main
swh-db-init=swh.core.cli.db:db_init
[swh.cli.subcommands]
- db=swh.core.cli.db:db
- db-init=swh.core.cli.db:db_init
+ db=swh.core.cli.db
[pytest11]
pytest_swh_core = swh.core.pytest_plugin
""",
diff --git a/swh/core/cli/__init__.py b/swh/core/cli/__init__.py
--- a/swh/core/cli/__init__.py
+++ b/swh/core/cli/__init__.py
@@ -5,6 +5,7 @@
import logging
import logging.config
+import warnings
import click
import pkg_resources
@@ -117,7 +118,17 @@
for entry_point in pkg_resources.iter_entry_points("swh.cli.subcommands"):
try:
cmd = entry_point.load()
- swh.add_command(cmd, name=entry_point.name)
+ if isinstance(cmd, click.BaseCommand):
+ # for BW compat, auto add click commands
+ warnings.warn(
+ f"{entry_point.name}: automagic addition of click commands "
+ f"to the main swh group is deprecated",
+ DeprecationWarning,
+ )
+ swh.add_command(cmd, name=entry_point.name)
+ # otherwise it's expected to be a module which has been loaded
+ # it's the responsibility of the click commands/groups in this
+ # module to transitively have the main swh group as parent.
except Exception as e:
logger.warning("Could not load subcommand %s: %s", entry_point.name, str(e))

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 30, 10:16 AM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216011

Event Timeline