Skip to content

Commit

Permalink
feat(cli): add --generator option to py generate (#758)
Browse files Browse the repository at this point in the history
## Change Summary

closes #757

## Checklist

- [ ] Unit tests for the changes exist
- [ ] Tests pass without significant drop in coverage
- [ ] Documentation reflects changes where applicable
- [ ] Test snapshots have been
[updated](https://prisma-client-py.readthedocs.io/en/latest/contributing/contributing/#snapshot-tests)
if applicable

## Agreement

By submitting this pull request, I confirm that you can use, modify,
copy and redistribute this contribution, under the terms of your choice.
  • Loading branch information
RobertCraigie authored May 30, 2023
1 parent 63935b2 commit 8a26e65
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/prisma/cli/commands/generate.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import logging
from pathlib import Path
from typing import Optional, Dict, Any
from typing import Optional, Dict, Any, Tuple

import click
import pydantic
Expand Down Expand Up @@ -38,7 +38,14 @@
type=int,
help='Depth to generate pseudo-recursive types to; -1 signifies fully recursive types',
)
def cli(schema: Optional[Path], watch: bool, **kwargs: Any) -> None:
@click.option(
'--generator',
multiple=True,
help='Specifies which generator to use. Can be specified multiple times. By default, all generators will be ran',
)
def cli(
schema: Optional[Path], watch: bool, generator: Tuple[str], **kwargs: Any
) -> None:
"""Generate prisma artifacts with modified config options"""
if pydantic.VERSION.split('.') < ['1', '8']:
warning(
Expand All @@ -53,6 +60,10 @@ def cli(schema: Optional[Path], watch: bool, **kwargs: Any) -> None:
if watch:
args.append('--watch')

if generator:
for name in generator:
args.append(f'--generator={name}')

env: Dict[str, str] = {}
prefix = 'PRISMA_PY_CONFIG_'
for key, value in kwargs.items():
Expand Down

0 comments on commit 8a26e65

Please sign in to comment.