click icon indicating copy to clipboard operation
click copied to clipboard

Allow Hiding of Range Values for IntRange Option in --help

Open jplindquist opened this issue 1 year ago • 4 comments

Related to #1525

Would it be possible to add a parameter or option that would disable the range output in the help message when using type click.IntRange. It looks like it was introduced as a fix and is always present, but in the expected behavior it seemed to indicate some desire to be able to toggle that on or off as needed. Maybe I'm misreading that though.

For example, I'm using count to set a log level / increase verbosity and I want to have a min/max range that I can specify, but I don't need it display the range. I'm OK with it silently defaulting to whatever the min / max are for the application in this case.

Sample

@click.option(
    "-v",
    "--verbose",
    "log_level",
    type=click.IntRange(0, 3 clamp=True),
    count=True,
    help="Increase Log Level (Can Be Repeated Multiple Times)",
)

Ideally I would be able to set something like type=click.IntRange(0, 3 clamp=True, show_range=False) like in the original issue to hide that as needed.

Thanks!

jplindquist avatar Feb 22 '24 04:02 jplindquist

Eventually, sure. Rather than continuing to add special cases though, this should be part of the help formatter refactor that needs to happen. An option should be able to collect a set of extra fields to display after its help text, from its param type for example. Right now the option has a ton of special cases, including for IntRange, which is becoming unmanageable.

davidism avatar Feb 22 '24 04:02 davidism

Thanks! When you can, let me know if there's anything I can follow along with for that effort as it progresses.

jplindquist avatar Feb 22 '24 15:02 jplindquist