Skip to content

Added IntRange min and max preview to --help output#1586

Merged
davidism merged 1 commit into
pallets:masterfrom
IamCathal:coc-intrangepreview
Jun 25, 2020
Merged

Added IntRange min and max preview to --help output#1586
davidism merged 1 commit into
pallets:masterfrom
IamCathal:coc-intrangepreview

Conversation

@IamCathal
Copy link
Copy Markdown
Contributor

Issue #1525 requested to have the following output for using the --help flag on options of type IntRange:

Usage: test.py [OPTIONS]

  Simple program that greets NAME for a total of COUNT times.

Options:
  --count INTEGER RANGE  Number of greetings.  [default: 1-32 inclusive]
  --help                 Show this message and exit.

This can be used like as a regular click user would expect it to:

import click

@click.command()
@click.option("--count",type=click.IntRange(1, 32), show_default=True, default=1, help="Number of greetings.")
def hello(count):
    """Simple program that greets for a total of COUNT times."""
    for _ in range(count):
        click.echo("Hello!")

if __name__ == '__main__':
    hello()

Comment thread tests/test_options.py
Comment thread src/click/core.py Outdated
Comment thread tests/test_options.py
@IamCathal IamCathal requested a review from davidism June 17, 2020 17:59
Comment thread src/click/core.py Outdated
@IamCathal IamCathal requested a review from davidism June 17, 2020 21:31
@davidism davidism force-pushed the coc-intrangepreview branch from 78a5e6b to a0c73dc Compare June 25, 2020 01:47
@davidism davidism added this to the 8.0.0 milestone Jun 25, 2020
@davidism davidism merged commit e8de91d into pallets:master Jun 25, 2020
@davidism davidism linked an issue Jul 1, 2020 that may be closed by this pull request
@IamCathal IamCathal deleted the coc-intrangepreview branch July 6, 2020 13:39
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show range values for IntRange option --help

2 participants