Skip to content

Commit 784c7b1

Browse files
Remove redundant origin help message from subcommand (#54)
* Remove redundant origin help message from subcommand * fix test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent e0d38fb commit 784c7b1

2 files changed

Lines changed: 0 additions & 32 deletions

File tree

pyodide_cli/app.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
import click
1010
import typer
11-
from typer.main import solve_typer_info_help
12-
from typer.models import TyperInfo
1311

1412
from . import __version__
1513

@@ -147,29 +145,13 @@ def _entrypoint_to_version(entrypoint: EntryPoint) -> str:
147145
return dist.metadata["version"]
148146

149147

150-
def _inject_origin(docstring: str, origin: str) -> str:
151-
return f"{docstring}\n\n{origin}"
152-
153-
154148
def register_plugins():
155149
"""Register subcommands via the ``pyodide.cli`` entry-point"""
156150
eps = entry_points(group="pyodide.cli")
157151
plugins = {ep.name: (ep.load(), ep) for ep in eps}
158152

159153
for plugin_name, (module, ep) in plugins.items():
160154
pkgname = _entrypoint_to_pkgname(ep)
161-
origin_text = f"Registered by {pkgname}:"
162-
163-
if isinstance(module, typer.Typer):
164-
typer_info = TyperInfo(module)
165-
help_with_origin = _inject_origin(
166-
solve_typer_info_help(typer_info), origin_text
167-
)
168-
else:
169-
help_with_origin = _inject_origin(
170-
getattr(module, "__doc__", ""), origin_text
171-
)
172-
173155
if isinstance(module, click.Command):
174156
cmd = module
175157
elif isinstance(module, typer.Typer):
@@ -179,16 +161,12 @@ def register_plugins():
179161
app = typer.Typer()
180162
app.command(
181163
plugin_name,
182-
help=help_with_origin,
183164
**typer_kwargs,
184165
)(module)
185166
cmd = typer.main.get_command(app)
186167
else:
187168
raise RuntimeError(f"Invalid plugin: {plugin_name}")
188169

189-
# directly manipulate click Command help message
190-
cmd.help = help_with_origin
191-
192170
cli.add_command(cmd, name=plugin_name, origin=pkgname)
193171

194172

pyodide_cli/tests/test_cli.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,3 @@ def test_plugin_origin(plugins):
7070
msg = "Registered by plugin-test:"
7171

7272
assert msg in output
73-
74-
75-
@pytest.mark.parametrize(
76-
"entrypoint", ["plugin_test_app", "plugin_test_func", "plugin_test_cli"]
77-
)
78-
def test_plugin_origin_subcommand(plugins, entrypoint):
79-
output = check_output(["pyodide", entrypoint, "--help"]).decode("utf-8")
80-
msg = "Registered by plugin-test:"
81-
82-
assert msg in output

0 commit comments

Comments
 (0)