Skip to content
Myr

Update docs for enum choice (#2928)

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

authored by David Lord · committed by GitHub · parents 9ce34f2, fb240d2 · Browse files · 1 file+4 added−5 removed
This commit

State

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

Diff stats

1 file+4 added−5 removed

  • other:+4 added−5 removed

1 file+4 added−5 removed

modified:docs/parameter-types.rst+4 added-5 removed
31 unmodified lines
3233 import enum3435 class HashType(enum.Enum):36 MD5 = 'MD5'37 SHA1 = 'SHA1'36 MD5 = enum.auto()37 SHA1 = enum.auto()3839 @click.command()40 @click.option('--hash-type',41 type=click.Choice(HashType, case_sensitive=False))
11 unmodified lines
53 invoke(digest, args=['--hash-type=foo'])54 println()55 invoke(digest, args=['--help'])5657Since version 8.2.0 any iterable may be passed to :class:`Choice`, here58an ``Enum`` is used which will result in all enum values to be valid59choices.57Any iterable may be passed to :class:`Choice`. If an ``Enum`` is passed, the58names of the enum members will be used as valid choices.5960Choices work with options that have ``multiple=True``. If a ``default``61value is given with ``multiple=True``, it should be a list or tuple of62valid choices.
119 unmodified lines