pallets / pallets/click

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

Open
#2,679 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help output
Dominant language
Python
Stars
17.7k
Forks
2.3k
Avg merge
1d 30m
Merged PRs (30d)
18

Description

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!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at click.IntRange and trace how its range is rendered in the --help output. Add a way for callers to suppress the displayed range while retaining the configured minimum, maximum, and clamping behavior; done means the sample option's help omits the range when requested.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.