mirror of
https://github.com/NCBM/plyngent.git
synced 2026-11-07 23:47:54 +08:00
core/cli: drop Click --help from slash commands
Slash commands use add_help_option=False and empty options_metavar so /help shows Usage: /history [N] without a fake Options/--help section.
This commit is contained in:
@@ -64,7 +64,17 @@ ON_OFF = OnOffParam()
|
||||
|
||||
|
||||
class SlashGroup(click.Group):
|
||||
"""Click group for REPL slash commands (no process-level ownership)."""
|
||||
"""Click group for REPL slash commands (no process-level ownership).
|
||||
|
||||
Commands never expose Click's ``--help``; use ``/help`` / ``/help <cmd>``.
|
||||
"""
|
||||
|
||||
@override
|
||||
def command(self, *args: Any, **kwargs: Any) -> Any:
|
||||
# No auto --help; drop [OPTIONS] metavar when the command has no options.
|
||||
kwargs.setdefault("add_help_option", False)
|
||||
kwargs.setdefault("options_metavar", "")
|
||||
return super().command(*args, **kwargs)
|
||||
|
||||
@override
|
||||
def get_help(self, ctx: click.Context) -> str:
|
||||
@@ -83,6 +93,7 @@ class SlashGroup(click.Group):
|
||||
slash = SlashGroup(
|
||||
"slash",
|
||||
help="REPL slash commands",
|
||||
add_help_option=False,
|
||||
context_settings={"help_option_names": [], "max_content_width": 100},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user