Skip to content
Myr

Fixes issue #514

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

Honored to fix the most +1'ed issue in click history, documenting the fact that options may be required=True.

authored by Robert Graham · committed by David Lord · parent d37ff75 · Browse files · 1 file+10 added−1 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+10 added−1 removed

  • other:+10 added−1 removed

1 file+10 added−1 removed

modified:docs/options.rst+10 added-1 removed
38 unmodified lines
39argument which is a value. If no type is provided, the type of the default40value is used. If no default value is provided, the type is assumed to be41:data:`STRING`. Unless a name is explicitly specified, the name of the42parameter is the first long option defined; otherwise the first short one is43used.43used. By default, options are not required, however to make an option required,44simply pass in `required=True` as an argument to the decorator.4546.. click:example::4748 @click.command()
2 unmodified lines
51 click.echo('.' * n)5253.. click:example::5455 # How to make an option required56 @click.command()57 @click.option('--n', required=True, type=int)58 def dots(n):59 click.echo('.' * n)6061.. click:example::6263 # How to use a Python reserved word such as `from` as a parameter64 @click.command()65 @click.option('--from', '-f', '_from')66 @click.option('--to', '-t')
730 unmodified lines