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

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

Open
jplindquist opened this issue Feb 22, 2024 · 2 comments
Open

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

jplindquist opened this issue Feb 22, 2024 · 2 comments

Comments

@jplindquist
Copy link

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!

@davidism
Copy link
Member

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.

@jplindquist
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants