click 8.2.1__tar.gz → 8.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {click-8.2.1 → click-8.2.2}/CHANGES.rst +20 -0
- {click-8.2.1 → click-8.2.2}/PKG-INFO +4 -2
- {click-8.2.1 → click-8.2.2}/README.md +3 -1
- click-8.2.2/docs/_static/click-icon.svg +11 -0
- click-8.2.2/docs/_static/click-logo.svg +18 -0
- click-8.2.2/docs/_static/click-name.svg +24 -0
- {click-8.2.1 → click-8.2.2}/docs/conf.py +2 -2
- click-8.2.2/docs/contrib.md +45 -0
- click-8.2.1/docs/documentation.rst → click-8.2.2/docs/documentation.md +71 -61
- {click-8.2.1 → click-8.2.2}/docs/entry-points.rst +2 -2
- {click-8.2.1 → click-8.2.2}/docs/index.rst +10 -10
- {click-8.2.1 → click-8.2.2}/docs/options.md +31 -6
- click-8.2.2/docs/parameters.md +55 -0
- click-8.2.2/docs/support-multiple-versions.md +62 -0
- click-8.2.2/docs/unicode-support.md +100 -0
- click-8.2.2/docs/utils.md +390 -0
- click-8.2.2/docs/virtualenv.md +58 -0
- click-8.2.2/docs/why.md +106 -0
- click-8.2.2/docs/wincmd.md +47 -0
- {click-8.2.1 → click-8.2.2}/pyproject.toml +1 -6
- {click-8.2.1 → click-8.2.2}/src/click/_termui_impl.py +1 -1
- {click-8.2.1 → click-8.2.2}/src/click/core.py +69 -26
- {click-8.2.1 → click-8.2.2}/src/click/exceptions.py +3 -3
- {click-8.2.1 → click-8.2.2}/src/click/shell_completion.py +21 -1
- {click-8.2.1 → click-8.2.2}/src/click/testing.py +12 -0
- {click-8.2.1 → click-8.2.2}/src/click/types.py +57 -13
- {click-8.2.1 → click-8.2.2}/src/click/utils.py +1 -1
- {click-8.2.1 → click-8.2.2}/tests/test_arguments.py +9 -13
- {click-8.2.1 → click-8.2.2}/tests/test_basic.py +9 -5
- {click-8.2.1 → click-8.2.2}/tests/test_imports.py +16 -15
- {click-8.2.1 → click-8.2.2}/tests/test_options.py +363 -19
- {click-8.2.1 → click-8.2.2}/tests/test_shell_completion.py +75 -0
- {click-8.2.1 → click-8.2.2}/tests/test_testing.py +2 -4
- {click-8.2.1 → click-8.2.2}/tests/test_types.py +6 -1
- {click-8.2.1 → click-8.2.2}/uv.lock +106 -95
- click-8.2.1/docs/Makefile +0 -20
- click-8.2.1/docs/_static/click-icon.png +0 -0
- click-8.2.1/docs/_static/click-logo-sidebar.png +0 -0
- click-8.2.1/docs/_static/click-logo.png +0 -0
- click-8.2.1/docs/contrib.rst +0 -58
- click-8.2.1/docs/make.bat +0 -36
- click-8.2.1/docs/parameters.rst +0 -58
- click-8.2.1/docs/unicode-support.rst +0 -112
- click-8.2.1/docs/utils.rst +0 -408
- click-8.2.1/docs/virtualenv.rst +0 -54
- click-8.2.1/docs/why.rst +0 -146
- click-8.2.1/docs/wincmd.rst +0 -64
- {click-8.2.1 → click-8.2.2}/LICENSE.txt +0 -0
- {click-8.2.1 → click-8.2.2}/docs/advanced.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/api.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/arguments.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/changes.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/click-concepts.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/commands-and-groups.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/commands.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/complex.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/exceptions.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/extending-click.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/faqs.md +0 -0
- {click-8.2.1 → click-8.2.2}/docs/handling-files.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/license.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/option-decorators.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/parameter-types.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/prompts.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/quickstart.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/setuptools.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/shell-completion.rst +0 -0
- {click-8.2.1 → click-8.2.2}/docs/testing.md +0 -0
- {click-8.2.1 → click-8.2.2}/src/click/__init__.py +0 -0
- {click-8.2.1 → click-8.2.2}/src/click/_compat.py +0 -0
- {click-8.2.1 → click-8.2.2}/src/click/_textwrap.py +0 -0
- {click-8.2.1 → click-8.2.2}/src/click/_winconsole.py +0 -0
- {click-8.2.1 → click-8.2.2}/src/click/decorators.py +0 -0
- {click-8.2.1 → click-8.2.2}/src/click/formatting.py +0 -0
- {click-8.2.1 → click-8.2.2}/src/click/globals.py +0 -0
- {click-8.2.1 → click-8.2.2}/src/click/parser.py +0 -0
- {click-8.2.1 → click-8.2.2}/src/click/py.typed +0 -0
- {click-8.2.1 → click-8.2.2}/src/click/termui.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/conftest.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/test_chain.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/test_command_decorators.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/test_commands.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/test_compat.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/test_context.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/test_custom_classes.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/test_defaults.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/test_formatting.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/test_info_dict.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/test_normalization.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/test_parser.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/test_termui.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/test_utils.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/typing/typing_aliased_group.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/typing/typing_confirmation_option.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/typing/typing_group_kw_options.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/typing/typing_help_option.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/typing/typing_options.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/typing/typing_password_option.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/typing/typing_progressbar.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/typing/typing_simple_example.py +0 -0
- {click-8.2.1 → click-8.2.2}/tests/typing/typing_version_option.py +0 -0
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
.. currentmodule:: click
|
|
2
2
|
|
|
3
|
+
Version 8.2.2
|
|
4
|
+
-------------
|
|
5
|
+
|
|
6
|
+
Released 2025-07-31
|
|
7
|
+
|
|
8
|
+
- Fix reconciliation of `default`, `flag_value` and `type` parameters for
|
|
9
|
+
flag options, as well as parsing and normalization of environment variables.
|
|
10
|
+
:issue:`2952` :pr:`2956`
|
|
11
|
+
- Fix typing issue in ``BadParameter`` and ``MissingParameter`` exceptions for the
|
|
12
|
+
parameter ``param_hint`` that did not allow for a sequence of string where the
|
|
13
|
+
underlying functino ``_join_param_hints`` allows for it. :issue:`2777` :pr:`2990`
|
|
14
|
+
- Use the value of ``Enum`` choices to render their default value in help
|
|
15
|
+
screen. Refs :issue:`2911` :pr:`3004`
|
|
16
|
+
- Fix completion for the Z shell (``zsh``) for completion items containing
|
|
17
|
+
colons. :issue:`2703` :pr:`2846`
|
|
18
|
+
- Don't include envvar in error hint when not configured. :issue:`2971` :pr:`2972`
|
|
19
|
+
- Fix a rare race in ``click.testing.StreamMixer``'s finalization that manifested
|
|
20
|
+
as a ``ValueError`` on close in a multi-threaded test session.
|
|
21
|
+
:issue:`2993` :pr:`2991`
|
|
22
|
+
|
|
3
23
|
Version 8.2.1
|
|
4
24
|
-------------
|
|
5
25
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: click
|
|
3
|
-
Version: 8.2.
|
|
3
|
+
Version: 8.2.2
|
|
4
4
|
Summary: Composable command line interface toolkit
|
|
5
5
|
Maintainer-email: Pallets <contact@palletsprojects.com>
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -19,7 +19,9 @@ Project-URL: Documentation, https://click.palletsprojects.com/
|
|
|
19
19
|
Project-URL: Donate, https://palletsprojects.com/donate
|
|
20
20
|
Project-URL: Source, https://github.com/pallets/click/
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
<div align="center"><img src="https://raw.githubusercontent.com/pallets/click/refs/heads/stable/docs/_static/click-name.svg" alt="" height="150"></div>
|
|
23
|
+
|
|
24
|
+
# Click
|
|
23
25
|
|
|
24
26
|
Click is a Python package for creating beautiful command line interfaces
|
|
25
27
|
in a composable way with as little code as necessary. It's the "Command
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center"><img src="https://raw.githubusercontent.com/pallets/click/refs/heads/stable/docs/_static/click-name.svg" alt="" height="150"></div>
|
|
2
|
+
|
|
3
|
+
# Click
|
|
2
4
|
|
|
3
5
|
Click is a Python package for creating beautiful command line interfaces
|
|
4
6
|
in a composable way with as little code as necessary. It's the "Command
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
3
|
+
<svg width="100%" height="100%" viewBox="0 0 500 500" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
|
4
|
+
<rect id="Icon" x="0" y="0" width="500" height="500" style="fill:none;"/>
|
|
5
|
+
<g>
|
|
6
|
+
<path d="M448.569,446.761l-66.389,49.07c-3.528,2.565 -8.018,4.169 -12.508,4.169l-136.626,-0c-19.243,-0 -28.223,-23.733 -14.112,-36.562l54.843,-49.07c3.849,-3.528 8.66,-5.452 14.112,-5.452l147.851,-0c20.526,-0 28.865,25.657 12.829,37.845Z" style="fill:#5c549e;fill-rule:nonzero;"/>
|
|
7
|
+
<path d="M192.956,406.03l-91.404,84.028c-6.415,6.414 -15.074,9.942 -23.734,9.942c-8.659,-0 -17.318,-3.528 -23.733,-9.942c-13.47,-13.47 -13.47,-34.317 0,-47.467l32.713,-36.561l106.158,-0Z" style="fill:#5c549e;fill-rule:nonzero;"/>
|
|
8
|
+
<path d="M328.299,216.485l-113.855,-102.309l-109.685,-0l124.118,135.343l-124.118,135.343l108.723,-0.321l114.817,-101.988c8.66,-9.301 13.15,-21.167 12.829,-33.355c0.321,-11.225 -4.169,-23.412 -12.829,-32.713Z" style="fill:#5c549e;fill-rule:nonzero;"/>
|
|
9
|
+
<path d="M191.994,93.97l-91.405,-84.028c-6.414,-6.414 -15.073,-9.942 -23.733,-9.942c-8.659,0 -17.319,3.528 -23.733,9.942c-13.47,13.47 -13.47,34.317 0,47.467l33.034,36.561l105.837,0Z" style="fill:#5c549e;fill-rule:nonzero;"/>
|
|
10
|
+
</g>
|
|
11
|
+
</svg>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
3
|
+
<svg width="100%" height="100%" viewBox="0 0 500 500" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
|
4
|
+
<rect id="Logo" x="0" y="0" width="500" height="500" style="fill:none;"/>
|
|
5
|
+
<g>
|
|
6
|
+
<path id="Box" d="M500,50l0,400c0,27.596 -22.404,50 -50,50l-400,0c-27.596,0 -50,-22.404 -50,-50l0,-400c0,-27.596 22.404,-50 50,-50l400,0c27.596,0 50,22.404 50,50Z" style="fill:url(#_Linear1);"/>
|
|
7
|
+
<path id="Shadow" d="M500,432.911l0,17.089c0,27.596 -22.404,50 -50,50l-211.576,0l-105.636,-105.637c3.812,3.641 8.857,5.637 13.903,5.637c5.196,0 10.391,-2.117 14.24,-5.965l54.843,-50.417l-40.218,-0l-12.701,-12.701l65.234,-0.192l68.891,-61.193c5.195,-5.581 7.889,-12.701 7.697,-20.013c0.192,-6.735 -2.502,-14.048 -7.697,-19.628l203.02,203.02Zm-284.804,-276.529l12.124,12.123l-63.503,0l-12.123,-12.123l63.502,0Zm153.945,211.674c9.622,-7.312 4.619,-22.706 -7.697,-22.706l-88.711,-0c-3.271,-0 -6.157,1.154 -8.467,3.271l-32.905,29.442c-8.467,7.697 -3.079,21.937 8.467,21.937l81.975,0c2.694,0 5.388,-0.962 7.505,-2.502l39.833,-29.442Z" style="fill:#493e5e;"/>
|
|
8
|
+
<g id="Icon">
|
|
9
|
+
<path d="M369.141,368.056l-39.833,29.442c-2.117,1.54 -4.811,2.502 -7.505,2.502l-81.975,0c-11.546,0 -16.934,-14.24 -8.467,-21.937l32.905,-29.442c2.31,-2.117 5.196,-3.271 8.467,-3.271l88.711,-0c12.316,-0 17.319,15.394 7.697,22.706Z" style="fill:#fff;fill-rule:nonzero;"/>
|
|
10
|
+
<path d="M215.774,343.618l-54.843,50.417c-3.849,3.848 -9.044,5.965 -14.24,5.965c-5.196,0 -10.391,-2.117 -14.24,-5.965c-8.082,-8.082 -8.082,-20.59 0,-28.48l19.628,-21.937l63.695,-0Z" style="fill:#fff;fill-rule:nonzero;"/>
|
|
11
|
+
<path d="M296.98,229.891l-68.313,-61.386l-65.812,0l74.471,81.206l-74.471,81.206l65.234,-0.192l68.891,-61.193c5.195,-5.581 7.889,-12.701 7.697,-20.013c0.192,-6.735 -2.502,-14.048 -7.697,-19.628Z" style="fill:#fff;fill-rule:nonzero;"/>
|
|
12
|
+
<path d="M215.196,156.382l-54.842,-50.417c-3.849,-3.848 -9.045,-5.965 -14.24,-5.965c-5.196,0 -10.392,2.117 -14.24,5.965c-8.082,8.082 -8.082,20.59 -0,28.48l19.82,21.937l63.502,0Z" style="fill:#fff;fill-rule:nonzero;"/>
|
|
13
|
+
</g>
|
|
14
|
+
</g>
|
|
15
|
+
<defs>
|
|
16
|
+
<linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(3.06162e-14,500,-500,3.06162e-14,267.59,0)"><stop offset="0" style="stop-color:#d8a9ca;stop-opacity:1"/><stop offset="1" style="stop-color:#53519b;stop-opacity:1"/></linearGradient>
|
|
17
|
+
</defs>
|
|
18
|
+
</svg>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
3
|
+
<svg width="100%" height="100%" viewBox="0 0 679 300" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
|
4
|
+
<g>
|
|
5
|
+
<path id="Name" d="M410.6,166.725l19.35,0c0,13.6 -3.4,24.05 -10.2,31.35c-6.8,7.3 -16.4,10.95 -28.8,10.95c-27.3,0 -40.95,-16.05 -40.95,-48.15l0,-9c0,-25.3 7,-41.15 21,-47.55c5.5,-2.6 12.15,-3.9 19.95,-3.9c11.4,0 20.675,3.125 27.825,9.375c7.15,6.25 10.725,15.275 10.725,27.075l-19.5,0c-1.1,-5.9 -3.05,-10.35 -5.85,-13.35c-2.8,-3 -7.2,-4.5 -13.2,-4.5c-7,0 -12.2,2.2 -15.6,6.6c-2.4,3.1 -3.8,8.4 -4.2,15.9c-0.2,2.4 -0.3,5.65 -0.3,9.75l0,9.3c0,11.5 1.6,19.35 4.8,23.55c3.3,4.2 8.425,6.3 15.375,6.3c6.95,0 11.75,-1.925 14.4,-5.775c2.65,-3.85 4.375,-9.825 5.175,-17.925Z" style="fill-rule:nonzero;"/>
|
|
6
|
+
<path d="M464.9,208.125l-19.5,0.15l0,-112.95l19.5,0l0,112.8Z" style="fill-rule:nonzero;"/>
|
|
7
|
+
<path d="M495.8,89.775c4.7,0 7.75,0.725 9.15,2.175c1.4,1.45 2.1,4.5 2.1,9.15c0,4.65 -0.725,7.7 -2.175,9.15c-1.45,1.45 -4.5,2.175 -9.15,2.175c-4.65,0 -7.7,-0.75 -9.15,-2.25c-1.45,-1.5 -2.175,-4.55 -2.175,-9.15c0,-4.6 0.725,-7.625 2.175,-9.075c1.45,-1.45 4.525,-2.175 9.225,-2.175Zm9.6,118.35l-19.5,0l0,-82.5l19.5,0l0,82.5Z" style="fill-rule:nonzero;"/>
|
|
8
|
+
<path d="M570.95,176.775l17.7,-0.15c-0.1,0.8 -0.2,2.25 -0.3,4.35c-0.1,2.1 -0.175,3.525 -0.225,4.275c-0.05,0.75 -0.175,1.925 -0.375,3.525c-0.2,1.6 -0.425,2.775 -0.675,3.525c-0.25,0.75 -0.575,1.725 -0.975,2.925c-1.8,5.2 -6.7,9.3 -14.7,12.3c-5.1,1.8 -10.425,2.7 -15.975,2.7c-5.55,-0 -10.575,-0.9 -15.075,-2.7c-4.5,-1.8 -8.05,-4.1 -10.65,-6.9c-5.9,-6.2 -8.85,-17.825 -8.85,-34.875c0,-17.05 2.95,-28.675 8.85,-34.875c2.6,-2.8 6.15,-5.1 10.65,-6.9c4.5,-1.8 9.5,-2.7 15,-2.7c10.8,0 19,2.7 24.6,8.1c5.6,5.4 8.4,12.9 8.4,22.5l-17.7,0c0,-4.4 -1.1,-7.675 -3.3,-9.825c-2.2,-2.15 -6.275,-3.225 -12.225,-3.225c-5.95,-0 -9.9,1.85 -11.85,5.55c-1.95,3.7 -2.925,9.25 -2.925,16.65l0,7.8c0,11.9 2.3,19.2 6.9,21.9c2.1,1.3 4.85,1.95 8.25,1.95c3.4,-0 6.175,-0.325 8.325,-0.975c2.15,-0.65 3.7,-1.775 4.65,-3.375c0.95,-1.6 1.575,-3.175 1.875,-4.725c0.3,-1.55 0.5,-3.825 0.6,-6.825Z" style="fill-rule:nonzero;"/>
|
|
9
|
+
<path d="M678.65,208.125l-23.4,0l-22.5,-30.3l-8.55,12.15l0,18.15l-19.5,0l0,-112.8l19.5,0l0,71.25l27.3,-40.65l22.05,0l-28.05,38.4l33.15,43.8Z" style="fill-rule:nonzero;"/>
|
|
10
|
+
<g id="Logo">
|
|
11
|
+
<path id="Box" d="M300,30l0,240c0,16.557 -13.443,30 -30,30l-240,-0c-16.557,-0 -30,-13.443 -30,-30l0,-240c0,-16.557 13.443,-30 30,-30l240,0c16.557,0 30,13.443 30,30Z" style="fill:url(#_Linear1);"/>
|
|
12
|
+
<path id="Shadow" d="M300,259.747l0,10.253c0,16.557 -13.443,30 -30,30l-126.946,-0l-63.381,-63.382c2.287,2.184 5.314,3.382 8.342,3.382c3.117,0 6.234,-1.27 8.544,-3.579l32.905,-30.25l-24.131,-0l-7.62,-7.621l39.141,-0.115l41.334,-36.716c3.117,-3.348 4.734,-7.62 4.618,-12.008c0.116,-4.041 -1.501,-8.428 -4.618,-11.776l121.812,121.812Zm-170.882,-165.918l7.274,7.274l-38.102,0l-7.273,-7.274l38.101,0Zm92.367,127.005c5.773,-4.388 2.771,-13.624 -4.619,-13.624l-53.226,-0c-1.963,-0 -3.695,0.693 -5.08,1.963l-19.744,17.665c-5.08,4.618 -1.847,13.162 5.081,13.162l49.185,0c1.616,0 3.233,-0.577 4.503,-1.501l23.9,-17.665Z" style="fill:#493e5e;"/>
|
|
13
|
+
<g id="Icon">
|
|
14
|
+
<path d="M221.485,220.834l-23.9,17.665c-1.27,0.924 -2.887,1.501 -4.503,1.501l-49.185,0c-6.928,0 -10.161,-8.544 -5.081,-13.162l19.744,-17.665c1.385,-1.27 3.117,-1.963 5.08,-1.963l53.226,-0c7.39,-0 10.392,9.236 4.619,13.624Z" style="fill:#fff;fill-rule:nonzero;"/>
|
|
15
|
+
<path d="M129.464,206.171l-32.905,30.25c-2.31,2.309 -5.427,3.579 -8.544,3.579c-3.118,0 -6.235,-1.27 -8.544,-3.579c-4.85,-4.849 -4.85,-12.354 -0,-17.088l11.776,-13.162l38.217,-0Z" style="fill:#fff;fill-rule:nonzero;"/>
|
|
16
|
+
<path d="M178.188,137.935l-40.988,-36.832l-39.487,0l44.683,48.724l-44.683,48.723l39.141,-0.115l41.334,-36.716c3.117,-3.348 4.734,-7.62 4.618,-12.008c0.116,-4.041 -1.501,-8.428 -4.618,-11.776Z" style="fill:#fff;fill-rule:nonzero;"/>
|
|
17
|
+
<path d="M129.118,93.829l-32.906,-30.25c-2.309,-2.309 -5.426,-3.579 -8.544,-3.579c-3.117,0 -6.235,1.27 -8.544,3.579c-4.849,4.849 -4.849,12.354 0,17.088l11.893,13.162l38.101,0Z" style="fill:#fff;fill-rule:nonzero;"/>
|
|
18
|
+
</g>
|
|
19
|
+
</g>
|
|
20
|
+
</g>
|
|
21
|
+
<defs>
|
|
22
|
+
<linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.83697e-14,300,-300,1.83697e-14,160.554,0)"><stop offset="0" style="stop-color:#d8a9ca;stop-opacity:1"/><stop offset="1" style="stop-color:#53519b;stop-opacity:1"/></linearGradient>
|
|
23
|
+
</defs>
|
|
24
|
+
</svg>
|
|
@@ -51,7 +51,7 @@ html_sidebars = {
|
|
|
51
51
|
}
|
|
52
52
|
singlehtml_sidebars = {"index": ["project.html", "localtoc.html", "ethicalads.html"]}
|
|
53
53
|
html_static_path = ["_static"]
|
|
54
|
-
html_favicon = "_static/click-icon.
|
|
55
|
-
html_logo = "_static/click-logo
|
|
54
|
+
html_favicon = "_static/click-icon.svg"
|
|
55
|
+
html_logo = "_static/click-logo.svg"
|
|
56
56
|
html_title = f"Click Documentation ({version})"
|
|
57
57
|
html_show_sourcelink = False
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
(contrib)=
|
|
2
|
+
|
|
3
|
+
# click-contrib
|
|
4
|
+
|
|
5
|
+
As the user number of Click grows, more and more major feature requests are
|
|
6
|
+
made. To users, it may seem reasonable to include those features with Click;
|
|
7
|
+
however, many of them are experimental or aren't practical to support
|
|
8
|
+
generically. Maintainers have to choose what is reasonable to maintain in Click
|
|
9
|
+
core.
|
|
10
|
+
|
|
11
|
+
The [click-contrib](https://github.com/click-contrib/) GitHub organization exists as a place to collect third-party
|
|
12
|
+
packages that extend Click's features. It is also meant to ease the effort of
|
|
13
|
+
searching for such extensions.
|
|
14
|
+
|
|
15
|
+
Please note that the quality and stability of those packages may be different
|
|
16
|
+
from Click itself. While published under a common organization, they are still
|
|
17
|
+
separate from Click and the Pallets maintainers.
|
|
18
|
+
|
|
19
|
+
## Third-party projects
|
|
20
|
+
|
|
21
|
+
Other projects that extend Click's features are available outside the
|
|
22
|
+
[click-contrib](https://github.com/click-contrib/) organization.
|
|
23
|
+
|
|
24
|
+
Some of the most popular and actively maintained are listed below:
|
|
25
|
+
|
|
26
|
+
| Project | Description | Popularity | Activity |
|
|
27
|
+
|---------------------------------------------------------|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
|
|
28
|
+
| [Typer](https://github.com/fastapi/typer) | Use Python type hints to create CLI apps. |  |  |
|
|
29
|
+
| [rich-click](https://github.com/ewels/rich-click) | Format help output with Rich. |  |  |
|
|
30
|
+
| [click-app](https://github.com/simonw/click-app) | Cookiecutter template for creating new CLIs. |  |  |
|
|
31
|
+
| [Cloup](https://github.com/janluke/cloup) | Adds option groups, constraints, command aliases, help themes, suggestions and more. |  |  |
|
|
32
|
+
| [Click Extra](https://github.com/kdeldycke/click-extra) | Cloup + colorful `--help`, `--config`, `--show-params`, `--verbosity` options, etc. |  |  |
|
|
33
|
+
|
|
34
|
+
```{note}
|
|
35
|
+
To make it into the list above, a project:
|
|
36
|
+
|
|
37
|
+
- must be actively maintained (at least one commit in the last year)
|
|
38
|
+
- must have a reasonable number of stars (at least 20)
|
|
39
|
+
|
|
40
|
+
If you have a project that meets these criteria, please open a pull request
|
|
41
|
+
to add it to the list.
|
|
42
|
+
|
|
43
|
+
If a project is no longer maintained or does not meet the criteria above,
|
|
44
|
+
please open a pull request to remove it from the list.
|
|
45
|
+
```
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
Help Pages
|
|
2
|
-
===================
|
|
1
|
+
# Help Pages
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
```{currentmodule} click
|
|
4
|
+
```
|
|
5
5
|
|
|
6
6
|
Click makes it very easy to document your command line tools. For most things Click automatically generates help pages for you. By design the text is customizable, but the layout is not.
|
|
7
7
|
|
|
8
|
-
Help Texts
|
|
9
|
-
--------------
|
|
8
|
+
## Help Texts
|
|
10
9
|
|
|
11
10
|
Commands and options accept help arguments. For commands, the docstring of the function is automatically used if provided.
|
|
12
11
|
|
|
13
12
|
Simple example:
|
|
14
13
|
|
|
14
|
+
```{eval-rst}
|
|
15
15
|
.. click:example::
|
|
16
16
|
|
|
17
17
|
@click.command()
|
|
@@ -26,17 +26,18 @@ Simple example:
|
|
|
26
26
|
click.echo("Hello!")
|
|
27
27
|
|
|
28
28
|
.. click:run::
|
|
29
|
-
|
|
30
29
|
invoke(hello, args=['--help'])
|
|
30
|
+
```
|
|
31
31
|
|
|
32
|
+
## Command Short Help
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
------------------
|
|
35
|
-
|
|
36
|
-
For subcommands, a short help snippet is generated. By default, it's the first sentence of the docstring. If too long, then it will ellipsize what cannot be fit on a single line with ``...``. The short help snippet can also be overridden with ``short_help``:
|
|
34
|
+
For subcommands, a short help snippet is generated. By default, it's the first sentence of the docstring. If too long, then it will ellipsize what cannot be fit on a single line with `...`. The short help snippet can also be overridden with `short_help`:
|
|
37
35
|
|
|
36
|
+
```{eval-rst}
|
|
38
37
|
.. click:example::
|
|
39
38
|
|
|
39
|
+
import click
|
|
40
|
+
|
|
40
41
|
@click.group()
|
|
41
42
|
def cli():
|
|
42
43
|
"""A simple command line tool."""
|
|
@@ -45,39 +46,39 @@ For subcommands, a short help snippet is generated. By default, it's the first s
|
|
|
45
46
|
def init():
|
|
46
47
|
"""Initializes the repository."""
|
|
47
48
|
|
|
48
|
-
|
|
49
49
|
.. click:run::
|
|
50
|
-
|
|
51
50
|
invoke(cli, args=['--help'])
|
|
51
|
+
```
|
|
52
52
|
|
|
53
|
-
Command Epilog Help
|
|
54
|
-
-------------------
|
|
53
|
+
## Command Epilog Help
|
|
55
54
|
|
|
56
55
|
The help epilog is printed at the end of the help and is useful for showing example command usages or referencing additional help resources.
|
|
57
56
|
|
|
57
|
+
```{eval-rst}
|
|
58
58
|
.. click:example::
|
|
59
59
|
|
|
60
|
+
import click
|
|
61
|
+
|
|
60
62
|
@click.command(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
epilog='See https://example.com for more details',
|
|
64
|
+
)
|
|
63
65
|
def init():
|
|
64
66
|
"""Initializes the repository."""
|
|
65
67
|
|
|
66
|
-
|
|
67
68
|
.. click:run::
|
|
68
|
-
|
|
69
69
|
invoke(init, args=['--help'])
|
|
70
|
+
```
|
|
70
71
|
|
|
71
|
-
|
|
72
|
+
(documenting-arguments)=
|
|
72
73
|
|
|
73
|
-
Documenting Arguments
|
|
74
|
-
----------------------
|
|
74
|
+
## Documenting Arguments
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
{class}`click.argument` does not take a `help` parameter. This follows the Unix Command Line Tools convention of using arguments only for necessary things and documenting them in the command help text
|
|
77
77
|
by name. This should then be done via the docstring.
|
|
78
78
|
|
|
79
79
|
A brief example:
|
|
80
80
|
|
|
81
|
+
```{eval-rst}
|
|
81
82
|
.. click:example::
|
|
82
83
|
|
|
83
84
|
@click.command()
|
|
@@ -86,13 +87,13 @@ A brief example:
|
|
|
86
87
|
"""Print FILENAME."""
|
|
87
88
|
click.echo(filename)
|
|
88
89
|
|
|
89
|
-
|
|
90
90
|
.. click:run::
|
|
91
|
-
|
|
92
91
|
invoke(touch, args=['--help'])
|
|
92
|
+
```
|
|
93
93
|
|
|
94
94
|
Or more explicitly:
|
|
95
95
|
|
|
96
|
+
```{eval-rst}
|
|
96
97
|
.. click:example::
|
|
97
98
|
|
|
98
99
|
@click.command()
|
|
@@ -105,14 +106,14 @@ Or more explicitly:
|
|
|
105
106
|
click.echo(filename)
|
|
106
107
|
|
|
107
108
|
.. click:run::
|
|
108
|
-
|
|
109
109
|
invoke(touch, args=['--help'])
|
|
110
|
+
```
|
|
110
111
|
|
|
112
|
+
## Showing Defaults
|
|
111
113
|
|
|
112
|
-
|
|
113
|
-
---------------------------
|
|
114
|
-
To control the appearance of defaults pass ``show_default``.
|
|
114
|
+
To control the appearance of defaults pass `show_default`.
|
|
115
115
|
|
|
116
|
+
```{eval-rst}
|
|
116
117
|
.. click:example::
|
|
117
118
|
|
|
118
119
|
@click.command()
|
|
@@ -121,11 +122,12 @@ To control the appearance of defaults pass ``show_default``.
|
|
|
121
122
|
click.echo('.' * n)
|
|
122
123
|
|
|
123
124
|
.. click:run::
|
|
124
|
-
|
|
125
125
|
invoke(dots, args=['--help'])
|
|
126
|
+
```
|
|
126
127
|
|
|
127
|
-
For single option boolean flags, the default remains hidden if the default value is False even if show default is true.
|
|
128
|
+
For single option boolean flags, the default remains hidden if the default value is False, even if show default is set to true.
|
|
128
129
|
|
|
130
|
+
```{eval-rst}
|
|
129
131
|
.. click:example::
|
|
130
132
|
|
|
131
133
|
@click.command()
|
|
@@ -140,16 +142,18 @@ For single option boolean flags, the default remains hidden if the default value
|
|
|
140
142
|
click.echo('-' * n)
|
|
141
143
|
|
|
142
144
|
.. click:run::
|
|
143
|
-
|
|
144
145
|
invoke(dots, args=['--help'])
|
|
146
|
+
```
|
|
145
147
|
|
|
148
|
+
## Click's Wrapping Behavior
|
|
146
149
|
|
|
147
|
-
Click's Wrapping Behavior
|
|
148
|
-
----------------------------
|
|
149
150
|
Click's default wrapping ignores single new lines and rewraps the text based on the width of the terminal, to a maximum of 80 characters. In the example notice how the second grouping of three lines is rewrapped into a single paragraph.
|
|
150
151
|
|
|
152
|
+
```{eval-rst}
|
|
151
153
|
.. click:example::
|
|
152
154
|
|
|
155
|
+
import click
|
|
156
|
+
|
|
153
157
|
@click.command()
|
|
154
158
|
def cli():
|
|
155
159
|
"""
|
|
@@ -164,17 +168,20 @@ Click's default wrapping ignores single new lines and rewraps the text based on
|
|
|
164
168
|
"""
|
|
165
169
|
|
|
166
170
|
.. click:run::
|
|
167
|
-
|
|
168
171
|
invoke(cli, args=['--help'])
|
|
172
|
+
```
|
|
169
173
|
|
|
170
|
-
Escaping Click's Wrapping
|
|
171
|
-
|
|
172
|
-
Sometimes Click's wrapping can be a problem, such as when showing code examples where
|
|
174
|
+
## Escaping Click's Wrapping
|
|
175
|
+
|
|
176
|
+
Sometimes Click's wrapping can be a problem, such as when showing code examples where new lines are significant. This behavior can be escaped on a per-paragraph basis by adding a line with only `\b` . The `\b` is removed from the rendered help text.
|
|
173
177
|
|
|
174
178
|
Example:
|
|
175
179
|
|
|
180
|
+
```{eval-rst}
|
|
176
181
|
.. click:example::
|
|
177
182
|
|
|
183
|
+
import click
|
|
184
|
+
|
|
178
185
|
@click.command()
|
|
179
186
|
def cli():
|
|
180
187
|
"""First paragraph.
|
|
@@ -188,28 +195,27 @@ Example:
|
|
|
188
195
|
that will be rewrapped again.
|
|
189
196
|
"""
|
|
190
197
|
|
|
191
|
-
|
|
192
198
|
.. click:run::
|
|
193
|
-
|
|
194
199
|
invoke(cli, args=['--help'])
|
|
200
|
+
```
|
|
195
201
|
|
|
196
|
-
To change the rendering maximum width, pass
|
|
202
|
+
To change the rendering maximum width, pass `max_content_width` when calling the command.
|
|
197
203
|
|
|
198
|
-
|
|
204
|
+
```bash
|
|
205
|
+
cli(max_content_width=120)
|
|
206
|
+
```
|
|
199
207
|
|
|
200
|
-
|
|
208
|
+
## Truncating Help Texts
|
|
201
209
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
Truncating Help Texts
|
|
205
|
-
---------------------
|
|
206
|
-
|
|
207
|
-
Click gets :class:`Command` help text from the docstring. If you do not want to include part of the docstring, add the ``\f`` escape marker to have Click truncate the help text after the marker.
|
|
210
|
+
Click gets {class}`Command` help text from the docstring. If you do not want to include part of the docstring, add the `\f` escape marker to have Click truncate the help text after the marker.
|
|
208
211
|
|
|
209
212
|
Example:
|
|
210
213
|
|
|
214
|
+
```{eval-rst}
|
|
211
215
|
.. click:example::
|
|
212
216
|
|
|
217
|
+
import click
|
|
218
|
+
|
|
213
219
|
@click.command()
|
|
214
220
|
def cli():
|
|
215
221
|
"""First paragraph.
|
|
@@ -219,15 +225,16 @@ Example:
|
|
|
219
225
|
"""
|
|
220
226
|
|
|
221
227
|
.. click:run::
|
|
222
|
-
|
|
223
228
|
invoke(cli, args=['--help'])
|
|
229
|
+
```
|
|
224
230
|
|
|
231
|
+
(doc-meta-variables)=
|
|
225
232
|
|
|
226
|
-
Placeholder / Meta Variable
|
|
227
|
-
-----------------------------
|
|
233
|
+
## Placeholder / Meta Variable
|
|
228
234
|
|
|
229
|
-
The default placeholder variable (
|
|
235
|
+
The default placeholder variable ([meta variable](https://en.wikipedia.org/wiki/Metasyntactic_variable#IETF_Requests_for_Comments)) in the help pages is the parameter name in uppercase with underscores. This can be changed for Commands and Parameters with the `options_metavar` and `metavar` kwargs.
|
|
230
236
|
|
|
237
|
+
```{eval-rst}
|
|
231
238
|
.. click:example::
|
|
232
239
|
|
|
233
240
|
# This controls entry on the usage line.
|
|
@@ -240,28 +247,31 @@ The default placeholder variable (`meta variable <https://en.wikipedia.org/wiki/
|
|
|
240
247
|
for x in range(count):
|
|
241
248
|
click.echo(f"Hello {name}!")
|
|
242
249
|
|
|
243
|
-
Example:
|
|
250
|
+
# Example usage:
|
|
244
251
|
|
|
245
252
|
.. click:run::
|
|
246
|
-
|
|
247
253
|
invoke(hello, args=['--help'])
|
|
248
254
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
Help
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Help Parameter Customization
|
|
258
|
+
|
|
259
|
+
Help parameters are automatically added by Click for any command. The default is `--help` but can be overridden by the context setting {attr}`~Context.help_option_names`. Click also performs automatic conflict resolution on the default help parameter, so if a command itself implements a parameter named `help` then the default help will not be run.
|
|
252
260
|
|
|
253
|
-
This example changes the default parameters to
|
|
254
|
-
instead of just
|
|
261
|
+
This example changes the default parameters to `-h` and `--help`
|
|
262
|
+
instead of just `--help`:
|
|
255
263
|
|
|
264
|
+
```{eval-rst}
|
|
256
265
|
.. click:example::
|
|
257
266
|
|
|
267
|
+
import click
|
|
268
|
+
|
|
258
269
|
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
|
|
259
270
|
|
|
260
271
|
@click.command(context_settings=CONTEXT_SETTINGS)
|
|
261
272
|
def cli():
|
|
262
273
|
pass
|
|
263
274
|
|
|
264
|
-
|
|
265
275
|
.. click:run::
|
|
266
|
-
|
|
267
276
|
invoke(cli, ['-h'])
|
|
277
|
+
```
|
|
@@ -2,7 +2,7 @@ Packaging Entry Points
|
|
|
2
2
|
======================
|
|
3
3
|
|
|
4
4
|
It's recommended to write command line utilities as installable packages with
|
|
5
|
-
entry points instead telling users to run ``python hello.py``.
|
|
5
|
+
entry points instead of telling users to run ``python hello.py``.
|
|
6
6
|
|
|
7
7
|
A distribution package is a ``.whl`` file you install with pip or another Python
|
|
8
8
|
installer. You use a ``pyproject.toml`` file to describe the project and how it
|
|
@@ -55,7 +55,7 @@ Contents of ``pyproject.toml``:
|
|
|
55
55
|
]
|
|
56
56
|
|
|
57
57
|
[project.scripts]
|
|
58
|
-
hello = "hello:cli"
|
|
58
|
+
hello = "hello.hello:cli"
|
|
59
59
|
|
|
60
60
|
[build-system]
|
|
61
61
|
requires = ["flit_core<4"]
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
Welcome to Click
|
|
4
4
|
================
|
|
5
5
|
|
|
6
|
-
.. image:: _static/click-
|
|
6
|
+
.. image:: _static/click-name.svg
|
|
7
7
|
:align: center
|
|
8
|
-
:
|
|
9
|
-
:target: https://palletsprojects.com/p/click/
|
|
8
|
+
:height: 200px
|
|
10
9
|
|
|
11
10
|
Click is a Python package for creating beautiful command line interfaces
|
|
12
11
|
in a composable way with as little code as necessary. It's the "Command
|
|
@@ -58,7 +57,7 @@ You can get the library directly from PyPI::
|
|
|
58
57
|
pip install click
|
|
59
58
|
|
|
60
59
|
Documentation
|
|
61
|
-
|
|
60
|
+
==============
|
|
62
61
|
|
|
63
62
|
.. toctree::
|
|
64
63
|
:maxdepth: 2
|
|
@@ -66,7 +65,7 @@ Documentation
|
|
|
66
65
|
faqs
|
|
67
66
|
|
|
68
67
|
Tutorials
|
|
69
|
-
|
|
68
|
+
------------
|
|
70
69
|
.. toctree::
|
|
71
70
|
:maxdepth: 1
|
|
72
71
|
|
|
@@ -74,15 +73,16 @@ Tutorials
|
|
|
74
73
|
virtualenv
|
|
75
74
|
|
|
76
75
|
How to Guides
|
|
77
|
-
|
|
76
|
+
---------------
|
|
78
77
|
.. toctree::
|
|
79
78
|
:maxdepth: 1
|
|
80
79
|
|
|
81
80
|
entry-points
|
|
82
81
|
setuptools
|
|
82
|
+
support-multiple-versions
|
|
83
83
|
|
|
84
84
|
Conceptual Guides
|
|
85
|
-
|
|
85
|
+
-------------------
|
|
86
86
|
.. toctree::
|
|
87
87
|
:maxdepth: 1
|
|
88
88
|
|
|
@@ -90,7 +90,7 @@ Conceptual Guides
|
|
|
90
90
|
click-concepts
|
|
91
91
|
|
|
92
92
|
General Reference
|
|
93
|
-
|
|
93
|
+
--------------------
|
|
94
94
|
|
|
95
95
|
.. toctree::
|
|
96
96
|
:maxdepth: 1
|
|
@@ -116,7 +116,7 @@ General Reference
|
|
|
116
116
|
wincmd
|
|
117
117
|
|
|
118
118
|
API Reference
|
|
119
|
-
|
|
119
|
+
-------------------
|
|
120
120
|
|
|
121
121
|
.. toctree::
|
|
122
122
|
:maxdepth: 2
|
|
@@ -124,7 +124,7 @@ API Reference
|
|
|
124
124
|
api
|
|
125
125
|
|
|
126
126
|
About Project
|
|
127
|
-
|
|
127
|
+
===============
|
|
128
128
|
|
|
129
129
|
* This documentation is structured according to `Diataxis <https://diataxis.fr/>`_
|
|
130
130
|
|
|
@@ -152,8 +152,8 @@ To make an option take multiple values, pass in `nargs`. Note only a fixed numbe
|
|
|
152
152
|
|
|
153
153
|
## Multi Value Options as Tuples
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
```{versionadded} 4.0
|
|
156
|
+
```
|
|
157
157
|
|
|
158
158
|
As you can see that by using `nargs` set to a specific number each item in
|
|
159
159
|
the resulting tuple is of the same type. This might not be what you want.
|
|
@@ -289,8 +289,8 @@ If a forward slash(`/`) is contained in your option name already, you can split
|
|
|
289
289
|
click.echo(f"debug={debug}")
|
|
290
290
|
```
|
|
291
291
|
|
|
292
|
-
|
|
293
|
-
|
|
292
|
+
```{versionchanged} 6.0
|
|
293
|
+
```
|
|
294
294
|
|
|
295
295
|
If you want to define an alias for the second option only, then you will need to use leading whitespace to disambiguate the format string.
|
|
296
296
|
|
|
@@ -368,6 +368,31 @@ If a list is passed to `envvar`, the first environment variable found is picked.
|
|
|
368
368
|
|
|
369
369
|
```
|
|
370
370
|
|
|
371
|
+
Variable names are:
|
|
372
|
+
- [Case-insensitive on Windows but not on other platforms](https://github.com/python/cpython/blob/aa9eb5f757ceff461e6e996f12c89e5d9b583b01/Lib/os.py#L777-L789).
|
|
373
|
+
- Not stripped of whitespaces and should match the exact name provided to the `envvar` argument.
|
|
374
|
+
|
|
375
|
+
For flag options, there is two concepts to consider: the activation of the flag driven by the environment variable, and the value of the flag if it is activated.
|
|
376
|
+
|
|
377
|
+
The environment variable need to be interpreted, because values read from them are always strings. We need to transform these strings into boolean values that will determine if the flag is activated or not.
|
|
378
|
+
|
|
379
|
+
Here are the rules used to parse environment variable values for flag options:
|
|
380
|
+
- `true`, `1`, `yes`, `on`, `t`, `y` are interpreted as activating the flag
|
|
381
|
+
- `false`, `0`, `no`, `off`, `f`, `n` are interpreted as deactivating the flag
|
|
382
|
+
- The presence of the environment variable without value is interpreted as deactivating the flag
|
|
383
|
+
- Empty strings are interpreted as deactivating the flag
|
|
384
|
+
- Values are case-insensitive, so the `True`, `TRUE`, `tRuE` strings are all activating the flag
|
|
385
|
+
- Values are stripped of leading and trailing whitespaces before being interpreted, so the `" True "` string is transformed to `"true"` and so activates the flag
|
|
386
|
+
- If the flag option has a `flag_value` argument, passing that value in the environment variable will activate the flag, in addition to all the cases described above
|
|
387
|
+
- Any other value is interpreted as deactivating the flag
|
|
388
|
+
|
|
389
|
+
.. caution::
|
|
390
|
+
For boolean flags with a pair of values, the only recognized environment variable is the one provided to the `envvar` argument.
|
|
391
|
+
|
|
392
|
+
So an option defined as `--flag\--no-flag`, with a `envvar="FLAG"` parameter, there is no magical `NO_FLAG=<anything>` variable that is recognized. Only the `FLAG=<anything>` environment variable is recognized.
|
|
393
|
+
|
|
394
|
+
Once the status of the flag has been determine to be activated or not, the `flag_value` is used as the value of the flag if it is activated. If the flag is not activated, the value of the flag is set to `None` by default.
|
|
395
|
+
|
|
371
396
|
## Multiple Options from Environment Values
|
|
372
397
|
|
|
373
398
|
As options can accept multiple values, pulling in such values from
|
|
@@ -432,8 +457,8 @@ providing only the option's flag without a value will either show a
|
|
|
432
457
|
prompt or use its `flag_value`.
|
|
433
458
|
|
|
434
459
|
Setting `is_flag=False, flag_value=value` tells Click that the option
|
|
435
|
-
can still be passed a value, but only
|
|
436
|
-
`flag_value`.
|
|
460
|
+
can still be passed a value, but if only the flag is given, the
|
|
461
|
+
value will be `flag_value`.
|
|
437
462
|
|
|
438
463
|
```{eval-rst}
|
|
439
464
|
.. click:example::
|