mirror of
https://github.com/d3vyce/fastapi-toolsets.git
synced 2026-08-04 15:44:09 +00:00
feat: allow default context via FIXTURES_CONTEXT env var for fixtures load (#343)
This commit is contained in:
@@ -68,6 +68,20 @@ manager fixtures --help
|
|||||||
╰──────────────────────────────────────────────────────────────────────────────────╯
|
╰──────────────────────────────────────────────────────────────────────────────────╯
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `fixtures load`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
manager fixtures load [CONTEXTS]... [--strategy merge|insert|skip_existing] [--dry-run]
|
||||||
|
```
|
||||||
|
|
||||||
|
`CONTEXTS` defaults to `Context.BASE` when omitted, and can also be set via the `FIXTURES_CONTEXT` environment variable, handy for CI/deploy scripts that shouldn't need an explicit argument per environment:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
FIXTURES_CONTEXT=testing manager fixtures load
|
||||||
|
```
|
||||||
|
|
||||||
|
An explicit CLI argument always takes precedence over the environment variable.
|
||||||
|
|
||||||
## Custom CLI
|
## Custom CLI
|
||||||
|
|
||||||
You can extend the CLI by providing your own Typer app. The `manager` entry point will merge your app's commands with the built-in ones:
|
You can extend the CLI by providing your own Typer app. The `manager` entry point will merge your app's commands with the built-in ones:
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ async def load(
|
|||||||
ctx: typer.Context,
|
ctx: typer.Context,
|
||||||
contexts: Annotated[
|
contexts: Annotated[
|
||||||
list[str] | None,
|
list[str] | None,
|
||||||
typer.Argument(help="Contexts to load."),
|
typer.Argument(help="Contexts to load.", envvar="FIXTURES_CONTEXT"),
|
||||||
] = None,
|
] = None,
|
||||||
strategy: Annotated[
|
strategy: Annotated[
|
||||||
LoadStrategy,
|
LoadStrategy,
|
||||||
|
|||||||
Reference in New Issue
Block a user