Skip to content
Myr

Clarify environment variables section.

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

authored by unknown · committed by unknown · parent 50bfe23 · Browse files · 1 file+25 added−2 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+25 added−2 removed

  • other:+25 added−2 removed

1 file+25 added−2 removed

modified:docs/arguments.rst+25 added-2 removed
112 unmodified lines
113114Environment Variables115---------------------116117This feature is not recommended since it be confusing to users. Arguments can only pull environment variables from ? explicitly named environment variables. In that case, it can also be a list of different environment variables where the first one is picked. ?117Arguments can only pull from explicit environment variables, that is the118name of the environment variable(s) must be passed into ``click.argument``.119119Example usage:120Example usage checking one environment variable:121122.. click:example::123124 @click.command()
6 unmodified lines
131132.. click:run::133134 with isolated_filesystem():135 # Writing the file in the filesystem.136 with open('hello.txt', 'w') as f:137 f.write('Hello World!')138 invoke(echo, env={'SRC': 'hello.txt'})139140141Example usage checking multiple environment variables:142143.. click:example::144145 @click.command()146 @click.argument('src', envvar=['SRC', 'SRC_2'], type=click.File('r'))147 def echo(src):148 """Print value of SRC environment variable."""149 click.echo(src.read())150151And from the command line:152153.. click:run::154155 with isolated_filesystem():156 # Writing the file in the filesystem.157 with open('hello.txt', 'w') as f:158 f.write('Hello World from second variable!')159 invoke(echo, env={'SRC_2': 'hello.txt'})