mmpy_bot icon indicating copy to clipboard operation
mmpy_bot copied to clipboard

Duplicate content in click command help output

Open sw-dbrown opened this issue 2 years ago • 1 comments

Describe the bug

The output of help for commands created with click contains duplicate content and is sometimes oddly formatted.

How To Reproduce

Create a bot with the following listener:

@listen_to("dummy")
@click.command(
    context_settings=dict(
        allow_extra_args=True,
    ),
)
@click.option(
    "-o",
    "--opt",
    type=str,
    help="Help text for option",
)
@click.argument("args", nargs=-1)
def dummy(
    self,
    message,
    opt: str,
    args: List[str],
) -> None:
    """A description of the command

    More information here
    """

    return

Send the message dummy --help. This leads to the following (correct) output on the CLI of the bot:

Usage: MyPlugin [OPTIONS] [ARGS]...

  A description of the command

  More information here

Options:
  -o, --opt TEXT  Help text for option
  --help          Show this message and exit.

However, in Mattermost the following response is sent:

image

Expected behavior

The help text defined in the docstring should only be shown once and formatted consistently (ie. not mixing regular and verbatim text)

Operating Environment (please complete the following information):

  • mmpy_bot Version: 2.2.1
  • mattermostdriver/mattermostautodriver Version: 7.3.2/1.2.0
  • Mattermost Server Version: 7.4
  • Python Version: 3.9
  • OS: Linux

Additional context

sw-dbrown avatar Nov 30 '22 09:11 sw-dbrown

Editing my previous comment...

We may be doing the docstring handling twice.

Possibly the cause is:

https://github.com/attzonko/mmpy_bot/blob/f726ebe5a456932da408be173b2f1f511d9d33a8/mmpy_bot/function.py#L113

where we append the content to the docstring. If previously already added it would be added twice. Needs further testing but I don't currently have the time to dig into it.

Thanks for reporting

unode avatar Nov 30 '22 14:11 unode