Skip to content
Myr

Documentation fixes

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

authored by Kevin Yap · committed by Kevin Yap · parent 1b9e2c0 · Browse files · 6 files+145 added−145 removed
This commit

State

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

Diff stats

6 files+145 added−145 removed

  • other:+145 added−145 removed

6 files+145 added−145 removed

modified:docs/advanced.rst+18 added-18 removed
11 unmodified lines
1213Command Aliases14---------------1516Many tools support aliases for commands. For instance you can configure16Many tools support aliases for commands. For instance, you can configure17``git`` to accept ``git ci`` as alias for ``git commit``. Other tools18also support auto discovery for aliases by automatically shortening them.1920Click does not support this out of the box but it's very easy to customize21the :class:`Group` or any other :class:`MultiCommand` to provide this22functionality.2324As explained in :ref:`custom-multi-commands` a multi command can provide24As explained in :ref:`custom-multi-commands`, a multi command can provide25two methods: :meth:`~MultiCommand.list_commands` and26:meth:`~MultiCommand.get_command`. In this particular case you only need27to override the latter as you generally don't want to enumerate the28aliases on the help page to avoid confusion.2930This following example implements a subclass of :class:`Group` that31accepts a prefix for a command. So if there is a command called32``push`` it would accept ``pus`` as alias if it's unique:31accepts a prefix for a command. If there is a command called32``push`` it would accept ``pus`` as an alias if it's unique:3334.. click:example::3536 class AliasedGroup(click.Group):
9 unmodified lines
46 elif len(matches) == 1:47 return click.Group.get_command(self, ctx, matches[0])48 ctx.fail('Too many matches: %s' % ', '.join(sorted(matches)))4950And it can be used like this then:50And it can then be used like this:5152.. click:example::5354 @click.command(cls=AliasedGroup)
10 unmodified lines
6566Invoking Other Commands67-----------------------6869Sometimes it might be interesting to invoke one command from another70command. This is generally a pattern that is discouraged with click but69Sometimes, it might be interesting to invoke one command from another70command. This is a pattern that is generally discouraged with click but71possible nonetheless. For this you can use the :func:`Context.invoke`72or :func:`Context.forward` methods.7374They work similar but the difference is that :func:`Context.invoke` merely74They work similarly, but the difference is that :func:`Context.invoke` merely75invokes another command with the arguments you provide as a caller,76whereas :func:`Context.forward` fills in the arguments from the current77command. Both accept the command as first argument and everything else is78passed onwards as you would expect.77command. Both accept the command as the first argument and everything else78is passed onwards as you would expect.7980Example:8182.. click:example::
37 unmodified lines
120The main difference is that in optparse callbacks are invoked with the raw121value as it happens, whereas a callback in click is invoked after the122value has been fully converted.123124Generally the order of invocation is driven by the order in which the user125provides the arguments to the script. So if there is an option called126``--foo`` and an option called ``--bar`` and the user calls it as ``--bar127--foo`` then the callback for ``bar`` will fire before the one for ``foo``.124Generally, the order of invocation is driven by the order in which the user125provides the arguments to the script; if there is an option called ``--foo``126and an option called ``--bar`` and the user calls it as ``--bar127--foo``, then the callback for ``bar`` will fire before the one for ``foo``.128129There are two exceptions to this rule which are important to know:130131Eagerness:
1 unmodified line
133 evaluated before all non-eager parameters, but again in the order as134 they were provided on the command line by the user.135136 This is important for parameters that execute and exit like ``--help``137 and ``--version``. Both are eager parameters but whatever parameter137 and ``--version``. Both are eager parameters, but whatever parameter138 comes first on the command line will win and exit the program.139140Repeated parameters:141 If an option or argument is split up on the command line into multiple142 places because it's repeated (for instance ``--exclude foo --include143 baz --exclude bar``) the callback will fire based on the position of144 the first option. So in this case the callback will fire for143 baz --exclude bar``), the callback will fire based on the position of144 the first option. In this case, the callback will fire for145 ``exclude`` and it will be passed both options (``foo`` and146 ``bar``), then the callback for ``include`` will fire with ``baz``147 only.148
2 unmodified lines
151 value except the first. The reason for this is to allow composability152 through shell aliases that set defaults.153154Missing parameters:155 If a parameter is not defined on the command line the callback will155 If a parameter is not defined on the command line, the callback will156 still fire. This is different from how it works in optparse where157 undefined values do not fire the callback. Missing parameters fire158 their callbacks at the very end which makes it possible for them to159 default to values from a parameter that came before.
3 unmodified lines
modified:docs/arguments.rst+24 added-24 removed
67 unmodified lines
6869 If you come from ``argparse`` you might be missing support for setting70 ``nargs`` to ``+`` to indicate that at least one argument is required.7172 This is supported by setting ``required=True``. However this should72 This is supported by setting ``required=True``. However, this should73 not be used if you can avoid it as we believe scripts should gracefully74 degrade into becoming noops if a variadic argument is empty. The75 reason for this is that very often scripts are invoked with wildcard75 reason for this is that very often, scripts are invoked with wildcard76 inputs from the command line and they should not error out if the77 wildcard is empty.7879.. _file-args:8081File Arguments82--------------8384Since all the examples have already worked with file names it makes sense84Since all the examples have already worked with filenames, it makes sense85to explain how to deal with files properly. Command line tools are more86fun if they work with files the unix way which is to accept ``-`` as a86fun if they work with files the Unix way which is to accept ``-`` as a87special file that refers to stdin/stdout.8889Click supports this through the :class:`click.File` type which90intelligently handles files for you. It also deals with unicode and bytes90intelligently handles files for you. It also deals with Unicode and bytes91correctly for all versions of Python so your script stays very portable.9293Example:94
27 unmodified lines
122will be a unicode value always. Filenames unfortunately however can be123unicode or bytes depending on which operating system you're on. As such124the type is insufficient.125126Instead you should be using the :class:`Path` type which handles this127complexity for you. Not only will it return either bytes or unicode126Instead, you should be using the :class:`Path` type which handles this127complexity for you. Not only will it return either bytes or Unicode128depending on what makes more sense, but it will also be able to do some129basic checks for you such as existence checks.130131Example:
23 unmodified lines
155The :class:`FileType` type has one problem it needs to deal with and that156is to decide when to open a file. The default behavior is to be157"intelligent" about it. What this means is that it will open stdin/stdout158and files opened for reading immediately. This will directly give the159user feedback when a file cannot be opened. But it will only open files159user feedback when a file cannot be opened, but it will only open files160for writing the first time an IO operation is performed by wrapping the161file automatically in a special wrapper.162163This behavior can be forced by passing ``lazy=True`` or ``lazy=False`` to164the constructor. If the file is openened lazily it will fail on first IO164the constructor. If the file is opened lazily, it will fail on first IO165operation by raising an :exc:`FileError`.166167Since files opened for writing will typically immediatley empty the file,168the lazy mode should really only be disabled if the developer is 100% sure167Since files opened for writing will typically immediately empty the file,168the lazy mode should only be disabled if the developer is absolutely sure169that this is intended behavior.170171Forcing on lazy mode is also very useful to avoid resource handling172confusion. If a file is opened in lazy mode it will get a173``close_intelligently`` method that can help you figuring out if the file174needs closing or not. This is not needed for parameters, but it is171Forcing lazy mode is also very useful to avoid resource handling172confusion. If a file is opened in lazy mode, it will receive a173``close_intelligently`` method that can help figure out if the file174needs closing or not. This is not needed for parameters, but is175necessary for manually prompting with the :func:`prompt` function as you176do not know if a stream like stdout was openend (which was already open176do not know if a stream like stdout was opened (which was already open177before) or a real file that needs closing.178179Starting with click 2.0 it's also possible to open files in atomic mode by180passing ``atomic=True``. In atomic mode all writes go into a separate180passing ``atomic=True``. In atomic mode, all writes go into a separate181file in the same folder and upon completion the file will be moved over to182the original location. This is useful if a file regularly read by other183users is modified.184185Environment Variables186---------------------187188Like options, arguments can also get values from an environment variable.189Unlike options however this is only supported for explicitly named189Unlike options, however, this is only supported for explicitly named190environment variables.191192Example usage:193
12 unmodified lines
206 with open('hello.txt', 'w') as f:207 f.write('Hello World!')208 invoke(echo, env={'SRC': 'hello.txt'})209210In that case it can also be a list of different environment variables210In that case, it can also be a list of different environment variables211where the first one is picked.212213Generally this feature is not recommended because it can cause a lot of214confusion to the user.215216Arguments looking like Options216Arguments-Like Options217------------------------------218219Sometimes you want to process arguments that look like options. For220instance imagine you have a file named ``-foo.txt``. If you pass this as221such as an argument click will treat it as an option.220instance, imagine you have a file named ``-foo.txt``. If you pass this as221an argument in this manner, click will treat it as an option.222223To solve this, click does what any POSIX style command line script does223To solve this, click does what any POSIX style command line script does,224and that is to accept the string ``--`` as a separator for options and225arguments. After the ``--`` marker all further parameters are accepted as225arguments. After the ``--`` marker, all further parameters are accepted as226arguments.227228Example usage:229
13 unmodified lines
modified:docs/bashcomplete.rst+13 added-13 removed
1 unmodified line
2=============34.. versionadded:: 2.056Starting with click 2.0 there is built-in support for bash completion for6As of click 2.0, there is built-in support for Bash completion for7any click script. There are certain restrictions on when this completion8is available but for the most part it should just work.8is available, but for the most part it should just work.910Limitations11-----------1213Bash completion is only available if a script has been installed properly14and not executed through the ``python`` command. For information about15how to do that see :ref:`setuptools-integration`. Currently click also15how to do that see :ref:`setuptools-integration`. Also, click currently16only supports completion for bash.1718Currently bash completion is an internal feature that is not customizable.18Currently, bash completion is an internal feature that is not customizable.19This might be relaxed in future versions.2021What it Completes22-----------------2324Generally the bash completion support will complete subcommands and24Generally, the bash completion support will complete subcommands and25parameters. Subcommands are always listed whereas parameters only if at26least a dash has been provided. Example::2728 $ repo <TAB><TAB>29 clone commit copy delete setuser 29 clone commit copy delete setuser30 $ repo clone -<TAB><TAB>31 --deep --help --rev --shallow -r 31 --deep --help --rev --shallow -r3233Activation34----------3536In order to activate bash completion you need to inform bash that36In order to activate Bash completion you need to inform Bash that37completion is available for your script and how. Any click application38automatically provides support for that. The general way this works is39through a magic environment variable called ``_<PROG_NAME>_COMPLETE``39through a magic environment variable called ``_<PROG_NAME>_COMPLETE``,40where ``<PROG_NAME>`` is your application executable name in uppercase41with dashes replaced by underscores.4243So if your tool is called ``foo-bar`` then the magic variable is called43If your tool is called ``foo-bar``, then the magic variable is called44``_FOO_BAR_COMPLETE``. By exporting it with the ``source`` value it will45spit out the activation script which can be trivally activated.4647For instance to enable bash completion for your ``foo-bar`` script, this47For instance, to enable Bash completion for your ``foo-bar`` script, this48is what you would need to put into your ``.bashrc``::4950 eval "$(_FOO_BAR_COMPLETE=source foo-bar)"5152From this point onwards your script will have bash completion enabled.52From this point onwards your script will have Bash completion enabled.5354Activation Script55-----------------5657The above activation example will always invoke your application on58startup. This might be slowing down the shell activation time59significantly if you have many applications. Alternatively you could also60ship a file with the contents of that which is what git and other systems60ship a file with the contents of that which is what Git and other systems61are doing.6263This can be easily accomplished::64
5 unmodified lines
modified:docs/commands.rst+34 added-35 removed
8 unmodified lines
910Callback Invocation11-------------------1213For a regular command the callback is executed whenever the command runs.14So if the script is the only command it will always fire (unless a15parameter callback prevents it. This for instance happens if someone13For a regular command, the callback is executed whenever the command runs.14If the script is the only command it will always fire (unless a15parameter callback prevents it). This for instance happens if someone16passes ``--help`` to the script).1718For groups and multi commands the situation looks different. In that case18For groups and multi commands, the situation looks different. In this case,19the callback fires whenever a subcommand fires (unless this behavior is20changed). What this means in practice is that an outer command runs21when an inner command runs:22
18 unmodified lines
4142Nested Handling and Contexts43----------------------------4445As you can see from the earlier example the basic command group accepts a45As you can see from the earlier example, the basic command group accepts a46debug argument which is passed to its callback, but not to the sync47command itself. The sync command only accepts its own arguments.4849This allows tools to act completely independent of each other. But how49This allows tools to act completely independent of each other, but how50does one command talk to a nested one? The answer to this is the51:class:`Context`.5253Each time a command is invoked a new context is created and linked with the54parent context. Normally you can't see these contexts, but they are53Each time a command is invoked, a new context is created and linked with the54parent context. Normally, you can't see these contexts, but they are55there. Contexts are passed to parameter callbacks together with the56value automatically. Commands can also ask for the context to be passed57by marking themselves with the :func:`pass_context` decorator. In that58case the context is passed as first argument.58case, the context is passed as first argument.5960The context can also carry a program specified object that can be61used for the program's purposes. What this means is that you can build a62script like this:
13 unmodified lines
7677 if __name__ == '__main__':78 cli(obj={})7980If the object is provided each context will pass the object onwards to80If the object is provided, each context will pass the object onwards to81its children, but at any level a context's object can be overridden. To82reach to a parent ``context.parent`` can be used.82reach to a parent, ``context.parent`` can be used.8384In addition to that instead of passing an object down nothing stops the85application from modifying global state. For instance you could just flip84In addition to that, instead of passing an object down, nothing stops the85application from modifying global state. For instance, you could just flip86a global ``DEBUG`` variable and be done with it.8788Decorating Commands89-------------------9091As you have seen in the earlier example a decorator can change how a91As you have seen in the earlier example, a decorator can change how a92command is invoked. What actually happens behind the scenes is that93callbacks are always invoked through the :meth:`Context.invoke` method94which automatically invokes a command correctly (by either passing the95context or not).9697This is very useful when you want to write custom decorators. For98instance a common pattern would be to configure an object representing98instance, a common pattern would be to configure an object representing99state and then storing it on the context and then to use a custom100decorator to find the most recent object of this sort and pass it as first101argument.102103For instance the :func:`pass_obj` decorator can be implemented like this:103For instance, the :func:`pass_obj` decorator can be implemented like this:104105.. click:example::106107 from functools import update_wrapper
4 unmodified lines
112 return ctx.invoke(f, ctx.obj, *args, **kwargs)113 return update_wrapper(new_func, f)114115The :meth:`Context.invoke` command will automatically invoke the function116in the correct way. So the function will either be called with ``f(ctx,116in the correct way, so the function will either be called with ``f(ctx,117obj)`` or ``f(obj)`` depending on if it itself is decorated with118:func:`with_context`.119120This is a very powerful context that can be used to build very complex
2 unmodified lines
123124Group Invocation Without Command125--------------------------------126127By default a group or multi command is not invoked unless a subcommand is127By default, a group or multi command is not invoked unless a subcommand is128passed. In fact, not providing a command automatically passes ``--help``129by default. This behavior can be changed by passing130``invoke_without_command=True`` to a group. In that case the callback is130``invoke_without_command=True`` to a group. In that case, the callback is131always invoked instead of showing the help page. The context object also132includes information about if the invocation would go to a subcommand or133not.132includes information about whether or not the invocation would go to a133subcommand.134135Example:136137.. click:example::
11 unmodified lines
149 click.echo('The subcommand')150151And how it works in practice::152153 $ python tool.py 153 $ python tool.py154 I was invoked without subcommand155 $ python tool.py sync156 I am about to invoke sync157 The subcommand
2 unmodified lines
160161Custom Multi Commands162---------------------163164In addition to using :func:`click.group` you can also build your own164In addition to using :func:`click.group`, you can also build your own165custom multi commands. This is useful when you want to support commands166being loaded lazily from plugins.167168A custom multi command just needs to implement a list and load method:
39 unmodified lines
208209Merging Multi Commands210----------------------211212In addition to implementing custom multi commands it can also be212In addition to implementing custom multi commands, it can also be213interesting to merge multiple together into one script. While this is214generally not as recommended as nesting one below the other the merging214generally not as recommended as nesting one below the other, the merging215approach can be useful in some circumstances for a nicer shell experience.216217A default implementation for such a merging system is the218:class:`CommandCollection` class. It accepts a list of other multi219commands and makes the commands available on the same class. It accepts a220list of other multi commands and makes the commands available on the same221level.219commands and makes the commands available on the same level.220221Example usage:222223.. click:example::
26 unmodified lines
250.. click:run::251252 invoke(cli, prog_name='cli', args=['--help'])253256In case a command exists on more than one source, the first source wins.254In case a command exists in more than one source, the first source wins.255256Overriding Defaults257-------------------258261By default the default value for a parameter is pulled from the262``default`` flag that is provided when it's defined. But that's not the259By default, the default value for a parameter is pulled from the260``default`` flag that is provided when it's defined, but that's not the261only place defaults can be loaded from. The other place is the262:attr:`Context.default_map` (a dictionary) on the context. This allows265defaults to be loaded from a config file to override the regular defaults.263defaults to be loaded from a configuration file to override the regular264defaults.265266This is useful if you plug in some commands from another package but267you're not satisfied with the defaults.268269The default map can be nested arbitrarily for each subcommand and be271provided when the script is invoked. Alternatively it can also be272overriden at any point by commands. For instance a toplevel command could273load the defaults from a config file.270provided when the script is invoked. Alternatively, it can also be271overriden at any point by commands. For instance a top-level command could272load the defaults from a configuration file.273274Example usage:275276.. click:example::
26 unmodified lines
modified:docs/complex.rst+53 added-52 removed
3 unmodified lines
4====================56.. currentmodule:: click78Click is designed to write complex and simple CLI tools alike. However9the power of its design is the ability to arbitrarily nest systems10together. For instance in case you have ever used Django you will have11realized that it provides a command line utility. But so does Celery for12instance. So when using Celery with Django there are two tools that need8Click is designed to assist with the creation of complex and simple CLI tools9alike. However, the power of its design is the ability to arbitrarily nest10systems together. For instance, in case you have ever used Django, you will11have realized that it provides a command line utility, but so does Celery (for12instance). When using Celery with Django there are two tools that need13to interact with each other and be cross configured.1415In a theoretical world of two separate click command line utilities they16can solve this problem by nesting one inside the other. For instance the16can solve this problem by nesting one inside the other. For instance, the17web framework could also load the commands for the message queue18framework.1920Basic Concepts
4 unmodified lines
2526Contexts27````````2829Whenever a click command is executed a :class:`Context` object is created30which holds state for this particular invocation. For instance it31remembers parsed parameters, what command created it, which resources need32to be cleaned up at the end of the function and so forth. It also holds33an application defined object optionally.29Whenever a click command is executed, a :class:`Context` object is created30which holds state for this particular invocation. It remembers parsed31parameters, what command created it, which resources need to be cleaned up32at the end of the function, and so forth. It can also optionally hold an33application-defined object.3435Context objects build a linked list until they hit top one. Each context36is linked to the parent context. This allows a command to work below37another command and store its own information there without having to be38afraid of messing up the state of the parent command.3940Because the parent data is however available it's possible to navigate to40Because the parent data is available, however, it is 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 us to the next point.4546Calling Convention47``````````````````4849When a click command callback is executed it's passed all the non hidden50parameters as keyword arguments. Notably absent is the context. However51a callback can opt-into being passed the context object by marking itself49When a click command callback is executed, it's passed all the non-hidden50parameters as keyword arguments. Notably absent is the context. However,51a callback can opt into being passed the context object by marking itself52with :func:`pass_context`.5354So how do you invoke a command callback if you don't know if it should55receive the context or not? The answer is that the context itself56provides a helper function (:meth:`Context.invoke`) which can do this for57you. It accepts the callback as first argument and then invokes the58function correctly.5960Building a Git61--------------60Building a Git Clone61--------------------6263In this example we want to build a command line tool that resembles a64version control system a bit. Systems like git usually provide one64version control system. Systems like Git usually provide one65over-arching command that already accepts some parameters and66configuration, and then has extra subcommands that do other things.66configuration, and then have extra subcommands that do other things.6768The Root Command69````````````````7071At 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 register71At 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 the76state of our tool:
21 unmodified lines
9899So let's understand what this does. We create a group command which can100have subcommands. When it is invoked it will create an instance of a101``Repo`` class. This holds the state for our command line tool. In this102case it just remembers some parameters but at this point it could also103start loading config files and so on.102case it just remembers some parameters, but at this point it could also103start loading configuration files and so on.104105This state object is then remembered as :attr:`~Context.obj` on the106context. This is a special attribute where commands are supposed to107remember what they need to pass on to their children.108109In order for this to work we need to mark our function with110:func:`pass_context` because otherwise the context object would be109In order for this to work, we need to mark our function with110:func:`pass_context`, because otherwise the context object would be111entirely hidden from us.112113The First Child Command114```````````````````````115116So let's add our first child command to it. Let's go with the clone117command:116Let's add our first child command to it, the clone command:117118.. click:example::119120 @cli.command()
2 unmodified lines
123 def clone(src, dest):124 pass125126So now we have a clone command, but how do we get access to the repo? As128you can imagine one way is to use the :func:`pass_context` function which127you can imagine, one way is to use the :func:`pass_context` function which128again will make our callback also get the context passed on which we130memorized the repo. Even better there is a second version of this131decorator called :func:`pass_obj` which will just pass the stored object,132in our case the repo:129memorized the repo. However, there is a second version of this decorator130called :func:`pass_obj` which will just pass the stored object, (in our case131the repo):132133.. click:example::134135 @cli.command()
5 unmodified lines
141142Interleaved Commands143````````````````````144146While not relevant for this particular program we want to build there is147also quite good support for interleaving systems. Imagine for instance145While not relevant for the particular program we want to build, there is146also quite good support for interleaving systems. Imagine for instance that147there would be this super cool plugin for our version control system that148needs a lot of configuration and wants to store its own configuration as149:attr:`~Context.obj`. If we would then attach another command below that,151all the sudden we would get the plugin config instead of our repo object.150we would all of a sudden get the plugin configuration instead of our repo151object.152153One obvious way is to store a reference to the repo on the plugin but then154a command needs to be aware that it's attached below such a plugin.153One obvious way to remedy this is to store a reference to the repo in the154plugin, but then a command needs to be aware that it's attached below such a155plugin.156156There is a much better system by taking advantage of the linked nature of157contexts. We know that the plugin context is linked to the context that158created our repo. Because of that we can start a search for the last157There is a much better system that can built by taking advantage of the linked158nature of contexts. We know that the plugin context is linked to the context159that created our repo. Because of that, we can start a search for the last160level where the object stored on the context was a repo.161162Built-in support for this is provided by the :func:`make_pass_decorator`162factory which will create decorators for us that find objects (it163internally calls into :meth:`Context.find_object`). So in our case we164know that we want to find the closest ``Repo`` object. So let's make a163factory, which will create decorators for us that find objects (it164internally calls into :meth:`Context.find_object`). In our case, we165know that we want to find the closest ``Repo`` object, so let's make a166decorator for this:167168.. click:example::169170 pass_repo = click.make_pass_decorator(Repo)171171If we now use ``pass_repo`` instead of ``pass_obj`` we will always get a172If we now use ``pass_repo`` instead of ``pass_obj``, we will always get a173repo instead of something else:174175.. click:example::176
3 unmodified lines
180 @pass_repo181 def clone(repo, src, dest):182 pass183183Ensuring Objects184````````````````184Ensuring Object Creation185````````````````````````186187The above example only works if there was an outer command that created a188``Repo`` object and stored it on the context. For some more advanced use188cases this might be a problem for you. The default behavior of189:func:`make_pass_decorator` is to call into :meth:`Context.find_object`190which will find the object. If it can't find the object it will raise an189cases, this might become a problem. The default behavior of190:func:`make_pass_decorator` is to call :meth:`Context.find_object`191which will find the object. If it can't find the object, it will raise an192error. The alternative behavior is to use :meth:`Context.ensure_object`192which will find the object, or if it cannot find it, will create one and193which will find the object, and if it cannot find it, will create one and194store it on the innermost context. This behavior can also be enabled for195:func:`make_pass_decorator` by passing ``ensure=True``:196197.. click:example::198199 pass_repo = click.make_pass_decorator(Repo, ensure=True)200200In this case the innermost context gets such an object created if it's201In this case, the innermost context gets an object created if it is202missing. This might replace objects being placed there earlier. In this202case the command stays executable, even if the outer command does not run.203For this to work the object type needs to have a constructor that accepts203case, the command stays executable, even if the outer command does not run.204For this to work, the object type needs to have a constructor that accepts205no arguments.206207As such it runs standalone:208
12 unmodified lines
modified:docs/license.rst+3 added-3 removed
1License2=======34Click is licensed under a three clause BSD License. It basically means:5do whatever you want with it as long as the copyright in Click sticks4Click is licensed under a three-clause BSD License. It basically means:5do whatever you want with it as long as the copyright in click sticks6around, the conditions are not modified and the disclaimer is present.7Furthermore you must not use the names of the authors to promote derivatives7Furthermore, you must not use the names of the authors to promote derivatives8of the software without written consent.910License Text11------------
2 unmodified lines