diff --git a/src/click/core.py b/src/click/core.py index de129ec2c..1d809739c 100644 --- a/src/click/core.py +++ b/src/click/core.py @@ -2427,7 +2427,7 @@ def make_metavar(self, ctx: Context) -> str: if metavar is None: metavar = self.type.name.upper() - if self.nargs != 1: + if self.nargs != 1 or self.multiple: metavar += "..." return metavar diff --git a/tests/test_options.py b/tests/test_options.py index 2547cc99f..5c2695906 100644 --- a/tests/test_options.py +++ b/tests/test_options.py @@ -582,6 +582,18 @@ def cmd(arg, arg2): assert "1, 2" in result.output +def test_multiple_option_help_shows_repeated_metavar(runner): + @click.command() + @click.option("--foo", multiple=True, help="A list of foo strings.") + def cmd(foo): + pass + + result = runner.invoke(cmd, ["--help"]) + + assert not result.exception + assert "--foo TEXT... A list of foo strings." in result.output + + def test_show_default_default_map(runner): @click.command() @click.option("--arg", default="a", show_default=True)