Skip to content
Myr

add bool conversions for t and f

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

authored by axu2 · committed by axu2 · parent 81b2fda · Browse files · 2 files+4 added−4 removed
This commit

State

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

Diff stats

2 files+4 added−4 removed

  • other:+4 added−4 removed

2 files+4 added−4 removed

modified:click/types.py+2 added-2 removed
272 unmodified lines
273 def convert(self, value, param, ctx):274 if isinstance(value, bool):275 return bool(value)276 value = value.lower()277 if value in ('true', '1', 'yes', 'y'):277 if value in ('true', 't,' '1', 'yes', 'y'):278 return True279 elif value in ('false', '0', 'no', 'n'):279 elif value in ('false', 'f', '0', 'no', 'n'):280 return False281 self.fail('%s is not a valid boolean' % value, param, ctx)282283 def __repr__(self):
308 unmodified lines
modified:docs/parameters.rst+2 added-2 removed
45 unmodified lines
46 A parameter that only accepts floating point values.4748``bool`` / :data:`click.BOOL`:49 A parameter that accepts boolean values. This is automatically used50 for boolean flags. If used with string values ``1``, ``yes``, ``y``51 and ``true`` convert to `True` and ``0``, ``no``, ``n`` and ``false``50 for boolean flags. If used with string values ``1``, ``yes``, ``y``, ``t``51 and ``true`` convert to `True` and ``0``, ``no``, ``n``, ``f`` and ``false``52 convert to `False`.5354:data:`click.UUID`:55 A parameter that accepts UUID values. This is not automatically
68 unmodified lines