-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #262 from shunichironomura/improve-docs-index
Improve documentation
- Loading branch information
Showing
27 changed files
with
835 additions
and
418 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
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
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
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,3 +1,43 @@ | ||
# `CommandContext` | ||
|
||
::: capsula.CommandContext | ||
The [`CommandContext`](../reference/capsula/index.md#capsula.CommandContext) captures the output of shell commands. | ||
It can be created using the `capsula.CommandContext.builder` method or the `capsula.CommandContext.__init__` method. | ||
|
||
::: capsula.CommandContext.builder | ||
::: capsula.CommandContext.__init__ | ||
|
||
## Configuration example | ||
|
||
### Via `capsula.toml` | ||
|
||
```toml | ||
[pre-run] | ||
contexts = [ | ||
{ type = "CommandContext", command = "poetry check --lock", cwd = ".", cwd_relative_to_project_root = true }, | ||
] | ||
``` | ||
|
||
### Via `@capsula.context` decorator | ||
|
||
```python | ||
import capsula | ||
PROJECT_ROOT = capsula.search_for_project_root(__file__) | ||
|
||
@capsula.run() | ||
@capsula.context(capsula.CommandContext("poetry check --lock", cwd=PROJECT_ROOT), mode="pre") | ||
def func(): ... | ||
``` | ||
|
||
## Output example | ||
|
||
The following is an example of the output of the `CommandContext`, reported by the [`JsonDumpReporter`](../reporters/json_dump.md): | ||
|
||
```json | ||
"poetry check --lock": { | ||
"command": "poetry check --lock", | ||
"cwd": "/home/nomura/ghq/github.com/shunichironomura/capsula", | ||
"returncode": 0, | ||
"stdout": "All set!\n", | ||
"stderr": "" | ||
} | ||
``` |
Oops, something went wrong.