You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/commands.md
+73-52Lines changed: 73 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,58 +13,59 @@ At the module level, `click_extra` imports all elements from `click.*`, then all
13
13
Which means all elements not redefined by Click Extra fallback to Cloup. And if Cloup itself does not redefine them, they fallback to Click.
14
14
15
15
For example:
16
+
16
17
-`click_extra.echo` is a direct alias to `click.echo` because neither Click Extra or Cloup re-implements an `echo` helper.
17
18
-[`@cloup.option_group` is a specific feature of Cloup](https://cloup.readthedocs.io/en/stable/pages/option-groups.html) that is only implemented by it. It is not modified by Click Extra, and Click does not implement it. Still, `@click_extra.option_group` is a direct alias to Cloup's one.
18
19
-`@click_extra.timer` is a new decorator only implemented by Click Extra. So it is not a proxy of anything.
19
20
- As for `@click_extra.version_option`, it is a re-implementation of `@click.version_option`, and so overrides it. If you want to use its original version, import it directly from `click` namespace.
20
21
21
22
Here is some of the main decorators of Click Extra and how they wraps and extends Cloup and Click ones:
22
23
23
-
| Decorators from `click_extra`| Wrapped decorator | Base class|
This let you replace the preset options by your own set, tweak their order and fine-tune their defaults.
145
152
146
153
````{admonition} Duplicate options
147
-
:class: caution
154
+
---
155
+
class: caution
156
+
---
148
157
If you try to add option decorators to a command which already have them by default, you will end up with duplicate entries ([as seen in issue #232](https://github.com/kdeldycke/click-extra/issues/232)):
149
158
150
159
```{click:example}
@@ -194,7 +203,9 @@ For example, the [`--verbosity` option defaults to the `WARNING` level](logging.
194
203
If you manage your own `--verbosity` option, you can [pass the `default` argument to its decorator like we did above](#change-default-options):
195
204
196
205
```{click:example}
197
-
:emphasize-lines: 2,5
206
+
---
207
+
emphasize-lines: 2,5
208
+
---
198
209
import click
199
210
from click_extra import verbosity_option
200
211
@@ -207,7 +218,9 @@ def cli():
207
218
This also works in its class form:
208
219
209
220
```{click:example}
210
-
:emphasize-lines: 2,4
221
+
---
222
+
emphasize-lines: 2,4
223
+
---
211
224
import click
212
225
from click_extra import VerbosityOption
213
226
@@ -219,7 +232,9 @@ def cli():
219
232
With a `@click_extra.command` instead of `@click.command`, it is the same, you also have the alternative to pass a `default_map` via the `context_settings`:
0 commit comments