-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f31aef
commit e932115
Showing
6 changed files
with
83 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
🔖 [Table of Contents](../README.md) / [Oops, I Did It Again](README.md) | ||
|
||
# Oops, I Did It Again: Most Common Mistakes When Working with Zrb | ||
# Oops, I Did It Again: The Most Common Mistakes When Working with Zrb | ||
|
||
Collection of the most common mistakes when working with Zrb | ||
|
||
- [Defining Different Tasks With The Same Name](defining-different-tasks-with-the-same-name.md) | ||
> 💃 "I'm not that innocent" | ||
- [Not Registering A Task to A Runner](not-registering-a-task-to-a-runner.md) | ||
- [Defining Different Tasks With The Same Name Under The Same Group](defining-different-tasks-with-the-same-name-under-the-same-group.md) | ||
- [Using The Same Variable to Define Different Task](using-the-same-variable-to-define-different-task.md) | ||
|
||
<iframe width="560" height="315" src="https://www.youtube.com/embed/CduA0TULnow?si=SfK_jhrXpY_37PKT" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe> | ||
|
||
🔖 [Table of Contents](../README.md) / [Oops, I Did It Again](README.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
docs/oops-i-did-it-again/not-registering-a-task-to-a-runner.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
🔖 [Table of Contents](../README.md) / [Oops, I Did It Again](README.md) | ||
|
||
# Not Registering A Task to A Runner | ||
|
||
```python | ||
from zrb import CmdTask, runner | ||
|
||
hello = CmdTask( | ||
name='hello', | ||
cmd='echo "hello world"' | ||
) | ||
``` | ||
|
||
```bash | ||
zrb hello | ||
# task not found | ||
``` | ||
|
||
If you want your task to be available through the CLI, you need to register it to Zrb's runner. | ||
|
||
> __NOTE:__ A task that is not registered to Zrb's runner will not be available through the CLI, but can still be used as upstreams/checkers. | ||
# Avoiding the Problem | ||
|
||
Don't forget to register your task to Zrb's runner | ||
|
||
```python | ||
from zrb import CmdTask, runner | ||
|
||
hello = CmdTask( | ||
name='hello', | ||
cmd='echo "hello world"' | ||
) | ||
runner.register(hello) | ||
``` | ||
|
||
If you are using `@python_task` decorator, you can use `runner` property as follow: | ||
|
||
```python | ||
from typing import Any | ||
from zrb import python_task, runner | ||
|
||
@python_task( | ||
name='hello', | ||
runner=runner | ||
) | ||
def hello(*args: Any, **kwargs: Any): | ||
task = kwargs.get('_task') | ||
task.print_out('hello world') | ||
``` | ||
|
||
|
||
🔖 [Table of Contents](../README.md) / [Oops, I Did It Again](README.md) |
Empty file.