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: README.md
+21-36
Original file line number
Diff line number
Diff line change
@@ -201,52 +201,37 @@ click options or function keywords:
201
201
202
202
### Advanced: adding arguments to built-in commands
203
203
204
-
Instead of rewriting a command from scratch, a project may want to add a flag to a built-in `spin` command, or perhaps do some pre- or post-processing.
205
-
For this, we have to use an internal Click concept called a [context](https://click.palletsprojects.com/en/8.1.x/complex/#contexts).
206
-
Fortunately, we don't need to know anything about contexts other than that they allow us to execute commands within commands.
204
+
Instead of rewriting a command from scratch, a project may simply want to add a flag to an existing `spin` command, or perhaps do some pre- or post-processing.
205
+
For this purpose, we provide the `spin.util.extend_cmd` decorator.
207
206
208
-
We proceed by duplicating the function header of the existing command, and adding our own flag:
207
+
Here, we show how to add a `--extra` flag to the existing `build` function:
209
208
210
209
```python
211
210
from spin.cmds import meson
212
211
213
-
# Take this from the built-in implementation, in `spin.cmds.meson.build`:
214
212
213
+
@click.option("-e", "--extra", help="Extra test flag")
0 commit comments