click-contrib / click-repl

Subcommand REPL for click apps
MIT License
215 stars 41 forks source link

short_help not shown for commands #114

Open thomask77 opened 5 months ago

thomask77 commented 5 months ago

When I define commands like this

@click.command()
@click.argument('assignments', nargs=-1)
@click.pass_obj
def cmd_sp(obj, assignments):
    """Set parameters"""
    ...

The short help is not shown in the pop-up menu.

As a work-around, I modified click-repl like this:

--- a/Tests/click/third_party/click_repl/_completer.py
+++ b/Tests/click/third_party/click_repl/_completer.py
@@ -314,7 +314,17 @@ class ClickCompleter(Completer):
                             Completion(
                                 text_type(name),
                                 -len(incomplete),
-                                display_meta=getattr(command, "short_help", ""),
+
+                                # 2024-01-26, tk:
+                                #
+                                # There doesn't seem to be a short_help attribute..
+                                # use get_short_help_str() instead.
+                                #
+                                # See https://github.com/click-contrib/click-repl/issues/114
+                                #
+                                # display_meta=getattr(command, "short_help", ""),
+                                #
+                                display_meta=command.get_short_help_str(),
                             )
                         )

This makes it behave the same as the shell completion functions in click/core.py.