Skip to content
Myr

Merge branch 'main' into deduplicate-deprecated-message

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

authored by Rowlando13 · committed by GitHub · parents c040135, 63daae2 · Browse files · 2 files+45 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+45 added−0 removed

  • other:+45 added−0 removed

2 files+45 added−0 removed

modified:docs/options.md+42 added
228 unmodified lines
229230 invoke(commit, args=['-m', 'foo', '-m', 'bar', '-m', 'here'])231```232233## Combining short options234235Short options made of a single character can be combined into one argument: `-abc` is equivalent to `-a -b -c`. This is the standard POSIX behavior for short option stacking, and it is the reason a repeated flag like `-vvv` works with the [Counting](#counting) feature.236237```{eval-rst}238.. click:example::239240 @click.command()241 @click.option('-a', is_flag=True)242 @click.option('-b', is_flag=True)243 @click.option('-c', is_flag=True)244 def cli(a, b, c):245 click.echo(f"a={a} b={b} c={c}")246247.. click:run::248249 invoke(cli, args=['-a', '-b', '-c'])250 invoke(cli, args=['-abc'])251```252253If the last option in the combination takes a value, the value can either follow as the next argument or be attached directly:254255```{eval-rst}256.. click:example::257258 @click.command()259 @click.option('-v', is_flag=True)260 @click.option('-n', type=int)261 def cli(v, n):262 click.echo(f"v={v} n={n}")263264.. click:run::265266 invoke(cli, args=['-v', '-n', '5'])267 invoke(cli, args=['-vn', '5'])268 invoke(cli, args=['-vn5'])269```270271```{note}272Multi-character short option names are not supported. An argument like `-dbg` is interpreted as the combination of `-d`, `-b`, and `-g`, so Click reports `No such option: -d` if `-d` is not declared. For longer option names, use a long option with the `--` prefix (like `--debug`).273```274275## Counting276277To count the occurrence of an option, set `count=True`. If the option is not278passed on the command line, then the count is 0. Counting is commonly used for
400 unmodified lines
modified:CHANGES.rst+3 added
59 unmodified lines
60- Fix missing space between option help text and the ``(DEPRECATED)``61 label, and localize the option label so it matches the command label.62 The label and the ``DeprecationWarning`` reason suffix are now produced63 by shared helpers. :pr:`3423`64- Document short option stacking (``-abc`` is parsed as ``-a -b -c``) and65 clarify that multi-character short option names are not supported.66 :issue:`2779` :pr:`3431`6768Version 8.3.369-------------70
1364 unmodified lines