summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Ronacher <armin.ronacher@active-4.com>2014-05-21 20:04:05 +0200
committerArmin Ronacher <armin.ronacher@active-4.com>2014-05-21 20:04:05 +0200
commit61eb5e2b473b2c3ef1a03000be127f5042fd88dd (patch)
treed69d6e09309b8e52933ac4a1e724a061c3b70353
parenteeb1378b0872cddbdda15f0cded34ff66ccaebe8 (diff)
downloadclick-61eb5e2b473b2c3ef1a03000be127f5042fd88dd.tar.gz
Added multi envvar docs
-rw-r--r--docs/api.rst1
-rw-r--r--docs/options.rst37
2 files changed, 38 insertions, 0 deletions
diff --git a/docs/api.rst b/docs/api.rst
index 8e0ee67..dbce2c1 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -104,6 +104,7 @@ Types
.. autoclass:: IntRange
.. autoclass:: ParamType
+ :members:
Exceptions
----------
diff --git a/docs/options.rst b/docs/options.rst
index 0ac6978..5e2d8eb 100644
--- a/docs/options.rst
+++ b/docs/options.rst
@@ -424,6 +424,43 @@ And from the command line:
In that case it can also be a list of different environment variables
where the first one is picked.
+Multiple Values from Environment Values
+---------------------------------------
+
+As options can accept multiple values pulling in such values from
+environment variables (which are strings) is a bit more complex. The way
+click solves this is by leaving it up to the type to customize this
+behavior. For both ``multiple`` and ``nargs`` with other values than
+``1`` click will invoke the :meth:`ParamType.split_envvar_value` method to
+perform the splitting.
+
+The default implementation for all types is to split on whitespace. The
+exception to this rules are the :class:`File` and :class:`Path` types
+which both split according to the operating system's path splitting rules.
+On UNIX systems like Linux and OS X the splitting happens for those on
+every colon (``:``) and for Windows on a semicolon (``;``).
+
+Example usage:
+
+.. click:example::
+
+ @click.command()
+ @click.option('paths', '--path', envvar='PATHS', multiple=True,
+ type=click.Path())
+ def perform(paths):
+ for path in paths:
+ click.echo(path)
+
+ if __name__ == '__main__':
+ perform()
+
+And from the command line:
+
+.. click:run::
+
+ import os
+ invoke(perform, env={'PATHS': './foo/bar%s./test' % os.path.pathsep})
+
Other Prefix Characters
-----------------------