Skip to content
Myr

show IntRange min and max in --help output

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Cathal · committed by David Lord · parent 4aa8d79 · Browse files · 3 files+16 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+16 added−0 removed

  • tests:+10 added−0 removed
  • other:+6 added−0 removed

3 files+16 added−0 removed

modified:src/click/core.py+4 added
1934 unmodified lines
1935 else:1936 default_string = self.default1937 extra.append(f"default: {default_string}")19381939 if isinstance(self.type, IntRange):1940 if self.type.min is not None and self.type.max is not None:1941 extra.append(f"{self.type.min}-{self.type.max} inclusive")19421943 if self.required:1944 extra.append("required")1945 if extra:1946 extra_str = ";".join(extra)
128 unmodified lines
modified:tests/test_options.py+10 added
214 unmodified lines
215 assert "lambda" not in result.output216 assert "(current user)" in result.output217218219def test_intrange_default_help_text(runner):220 @click.command()221 @click.option("--count", type=click.IntRange(1, 32), show_default=True, default=1)222 def cmd(arg):223 click.echo(arg)224225 result = runner.invoke(cmd, ["--help"])226 assert "1-32 inclusive" in result.output227228229def test_toupper_envvar_prefix(runner):230 @click.command()231 @click.option("--arg")232 def cmd(arg):
335 unmodified lines
modified:CHANGES.rst+2 added
16 unmodified lines
17 ``importlib_metadata`` backport) instead of ``pkg_resources``.18 :issue:`1582`19- If validation fails for a prompt with ``hide_input=True``, the value20 is not shown in the error message. :issue:`1460`21- An ``IntRange`` option shows the accepted range in its help text.22 :issue:`1525`232425Version 7.1.226-------------
635 unmodified lines