Skip to content
Myr

Docs: fixed some spelling and punctuation mistakes

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

authored by Julen Ruiz Aizpuru · committed by Julen Ruiz Aizpuru · parent da717da · Browse files · 4 files+11 added−11 removed
This commit

State

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

Diff stats

4 files+11 added−11 removed

  • other:+11 added−11 removed

4 files+11 added−11 removed

modified:docs/arguments.rst+2 added-2 removed
33 unmodified lines
34unlimited) number of arguments is accepted. This can be controlled with35the ``nargs`` parameter. If it's set to ``-1`` then an unlimited number36of arguments is accepted.3738The value is then passed as tuple. Note that only one argument really can39be set to ``nargs=-1`` and right now only the last.38The value is then passed as a tuple. Note that only one argument really39can be set to ``nargs=-1`` and right now only the last.4041Example::4243 @click.command()
71 unmodified lines
modified:docs/complex.rst+2 added-2 removed
39 unmodified lines
40Because the parent data is however available it's possible to navigate to41it if needed.4243Most of the time you don't see the context object, but when writing more44complex applications it comes in handy. This brings is to the next point44complex applications it comes in handy. This brings us to the next point.4546Calling Convention47``````````````````48
18 unmodified lines
6768The Root Command69````````````````7071At the toplevel we need a group that can hold all our commands. In this71At the top level we need a group that can hold all our commands. In this72case we use the basic :func:`click.group` which allows us to register73other click commands below it.7475For this command we also want to accept some parameters that configure the
95 unmodified lines
modified:docs/options.rst+6 added-6 removed
28 unmodified lines
2930In this case the option is of type :data:`INT` because the default value31is an integer.3233The name of the parameter is the longest33The name of the parameter is the longest.3435Multi Value Options36-------------------3738Sometimes you have options that take more than one argument. For options39only a fixed number of arguments is supported. This can be configured by40the ``nargs`` parameter. The values are then stored as tuple:40the ``nargs`` parameter. The values are then stored as a tuple.4142Example::4344
76 unmodified lines
121122Feature Switches123----------------124125In addition to boolean flag there are also feature switches. These are125In addition to boolean flags there are also feature switches. These are126implemented by setting multiple options to the same parameter name and by127defining a flag value. To set a default flag assign a value of `True` to128the flag that should be the default.129
23 unmodified lines
153---------154155Sometimes you want parameters that can either be provided from the command156line or if not, you want to ask for user input. This can be implemented157with click by defining a prompt string:157with click by defining a prompt string.158159Example::160161 import os
58 unmodified lines
220---------------------------221222Sometimes you want a parameter to completely change the execution flow.223This for instance is the case when you want to have a ``--version``224parameter that prints out the version and then exists the application.224parameter that prints out the version and then exits the application.225226In such cases you need two concepts: eager parameters and a callback. An227eager parameter is a parameter that is handled before others and a228callback is what executes after the parameter is handled. The eagerness
80 unmodified lines
309This is supported by click in two ways. One is to automatically build310environment variables which is supported for options only. To enable this311feature the ``auto_envvar_prefix`` parameter needs to be passed to the312script that is invoked. Each command and parameter is then added as313underscore separated variable in uppercase. So if you have a subcommand313underscore-separated variable in uppercase. So if you have a subcommand314called ``foo`` taking an option called ``bar`` and the prefix is315``MY_TOOL`` then the variable is ``MY_TOOL_FOO_BAR``.316317Example usage::
36 unmodified lines
modified:docs/setuptools.rst+1 added-1 removed
52 unmodified lines
53 )5455The magic is in the ``entry_points`` parameter. Below ``console_scripts``56each line identifies one console script. The first part before the equals57sign (``=``) is the name of the script that should be generate, the second57sign (``=``) is the name of the script that should be generated, the second58part is the import path followed by a colon (``:``) with the click59command.6061That's it.
15 unmodified lines