Skip to content
Myr

Added multi envvar docs

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

authored by Armin Ronacher · committed by Armin Ronacher · parent eeb1378 · Browse files · 2 files+38 added−0 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+38 added−0 removed

  • other:+38 added−0 removed

2 files+38 added−0 removed

modified:docs/api.rst+1 added
102 unmodified lines
103104.. autoclass:: IntRange105106.. autoclass:: ParamType107 :members:108109Exceptions110----------111
32 unmodified lines
modified:docs/options.rst+37 added
422 unmodified lines
423424In that case it can also be a list of different environment variables425where the first one is picked.426427Multiple Values from Environment Values428---------------------------------------429430As options can accept multiple values pulling in such values from431environment variables (which are strings) is a bit more complex. The way432click solves this is by leaving it up to the type to customize this433behavior. For both ``multiple`` and ``nargs`` with other values than434``1`` click will invoke the :meth:`ParamType.split_envvar_value` method to435perform the splitting.436437The default implementation for all types is to split on whitespace. The438exception to this rules are the :class:`File` and :class:`Path` types439which both split according to the operating system's path splitting rules.440On UNIX systems like Linux and OS X the splitting happens for those on441every colon (``:``) and for Windows on a semicolon (``;``).442443Example usage:444445.. click:example::446447 @click.command()448 @click.option('paths', '--path', envvar='PATHS', multiple=True,449 type=click.Path())450 def perform(paths):451 for path in paths:452 click.echo(path)453454 if __name__ == '__main__':455 perform()456457And from the command line:458459.. click:run::460461 import os462 invoke(perform, env={'PATHS': './foo/bar%s./test' % os.path.pathsep})463464Other Prefix Characters465-----------------------466467Click can deal with alternative prefix characters, other than ``-`` for
60 unmodified lines