Skip to content
Myr

Document option no option pattern better (#3103)

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

authored by Rowlando13 · committed by GitHub · parents 8533c96, 9c2f183 · Browse files · 1 file+7 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+7 added−2 removed

  • other:+7 added−2 removed

1 file+7 added−2 removed

modified:docs/options.md+7 added-2 removed
255 unmodified lines
256 invoke(info, args=['--shout'])257258```259260To implement this more explicitly, pass in on-option `/` off-option. Click will automatically set `is_flag=True`. Click always wants you to provide an enable261and disable flag so that you can change the default later.260To implement this more explicitly, pass in on-option `/` off-option. Click will automatically set `is_flag=True`.261262```{eval-rst}263.. click:example::264
13 unmodified lines
278 invoke(info, args=['--shout'])279 invoke(info, args=['--no-shout'])280```281282Use cases for this more explicit pattern include:283284* The default can be dynamic so the user can explicitly specify the option with either on or off option, or pass in no option to use the dynamic default.285* Shell scripts sometimes want to be explicit even when it's the default286* Shell aliases can set a flag, then an invocation can add a negation of the flag287288If a forward slash(`/`) is contained in your option name already, you can split the parameters using `;`. In Windows `/` is commonly used as the prefix character.289290```{eval-rst}291.. click:example::
213 unmodified lines