Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate content in click command help output #362

Open
sw-dbrown opened this issue Nov 30, 2022 · 1 comment
Open

Duplicate content in click command help output #362

sw-dbrown opened this issue Nov 30, 2022 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@sw-dbrown
Copy link

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

@unode
Copy link
Collaborator

unode commented Nov 30, 2022

Editing my previous comment...

We may be doing the docstring handling twice.

Possibly the cause is:

self.docstring += f"\n\n{self.function.get_help(ctx)}"

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 unode added the bug Something isn't working label Nov 30, 2022
@attzonko attzonko added the help wanted Extra attention is needed label Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants