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/guides/cli.md
+54Lines changed: 54 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -259,3 +259,57 @@ apflow users stat
259
259
```
260
260
261
261
For more details on how to develop these extensions, see the [Extending Guide](../development/extending.md#creating-cli-extensions).
262
+
263
+
## Extending and Overriding CLI Commands
264
+
265
+
apflow allows you to register new CLI command groups or single commands, extend existing groups, or override built-in commands and groups. This is done using the `@cli_register` decorator, with the `group` and `override=True` parameters.
@cli_register(name="run", override=True, help="Override built-in run command")
303
+
defmy_run():
304
+
print("This is my custom run command!")
305
+
```
306
+
Now, running `apflow run` will execute your custom logic instead of the built-in command.
307
+
308
+
### Core Extension Override
309
+
310
+
apflow also supports custom extensions for executors, hooks, storage backends, and more. You can register your own or override built-in extensions by passing `override=True` when registering.
311
+
312
+
**Best Practices:**
313
+
- Use `override=True` only when you want to replace an existing command or extension.
314
+
- Keep extension logic simple and well-documented.
apflow supports a powerful extension system for both CLI commands and core functionality. You can add your own extensions or override existing ones, making it easy to customize and adapt apflow to your needs.
4
+
5
+
## CLI Extensions: Custom Commands and Overriding
6
+
7
+
You can register new CLI command groups or single commands using the `@cli_register` decorator. You can also extend or override existing commands and groups by specifying the `group` and `override=True` parameters.
8
+
9
+
For detailed usage and examples, see the [CLI Guide](./cli.md) and [Library Usage Guide](./library-usage.md).
10
+
11
+
## Core Extensions: Custom and Override
12
+
13
+
apflow also supports custom extensions for executors, hooks, storage backends, and more. You can register your own or override built-in extensions by passing `override=True` when registering.
14
+
15
+
For how to override executors and other extensions, see the [API Quick Reference](../api/quick-reference.md) and [Python API Reference](../api/python.md).
16
+
17
+
For more details, see the [Extending Guide](../development/extending.md).
18
+
19
+
For more details, see the [Extending Guide](../development/extending.md).
20
+
21
+
## Best Practices
22
+
- Use `override=True` only when you want to replace an existing command or extension.
23
+
- Keep extension logic simple and well-documented.
Copy file name to clipboardExpand all lines: docs/guides/library-usage.md
+58Lines changed: 58 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -406,6 +406,64 @@ This means your custom middleware runs **after** the default middleware, so it c
406
406
5.**Test middleware** thoroughly as it affects all requests
407
407
6.**Use type hints** for better code clarity
408
408
409
+
## Extending and Overriding CLI Commands and Extensions
410
+
411
+
apflow supports advanced extensibility for both CLI commands and core extensions. You can add your own commands, extend existing groups, or override built-in commands and extensions using simple decorators and parameters.
412
+
413
+
### CLI Command Extension and Override
414
+
415
+
416
+
You can register new CLI command groups or single commands using the `@cli_register` decorator. To extend an existing group, use the `group` parameter. To override an existing command or group, set `override=True`.
@cli_register(name="run", override=True, help="Override built-in run command")
453
+
defmy_run():
454
+
print("This is my custom run command!")
455
+
```
456
+
Now, running `apflow run` will execute your custom logic instead of the built-in command.
457
+
458
+
### Core Extension Override
459
+
460
+
apflow also supports custom extensions for executors, hooks, storage backends, and more. You can register your own or override built-in extensions by passing `override=True` when registering.
461
+
462
+
**Best Practices:**
463
+
- Use `override=True` only when you want to replace an existing command or extension.
464
+
- Keep extension logic simple and well-documented.
465
+
- Test your extensions thoroughly.
466
+
409
467
## Quick Reference: What main.py Does
410
468
411
469
For reference, here's what `apflow.api.main.main()` and `create_runnable_app()` do:
0 commit comments