From 74ce5bd8afd16c6a9aeb13ce8ebb71ab146c0ff0 Mon Sep 17 00:00:00 2001 From: Robert Hafner Date: Thu, 21 Nov 2024 11:15:54 -0600 Subject: [PATCH] Document regex include/exclude options --- README.md | 10 +++++++++- paracelsus/cli.py | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c5cbe46..da52347 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ from example_app.models import * ### Include or Exclude tables -After importing the models, it is possible to select a subset of those models by using the `--exlude-tables` and `--include-tables` options. +After importing the models, it is possible to select a subset of those models by using the `--exclude-tables` and `--include-tables` options. These are mutually exclusive options, the user can only provide inclusions or exclusions: ```bash @@ -91,6 +91,14 @@ paracelsus graph example_app.models.base:Base \ --include-tables "posts" ``` +You can also use regular expressions in the `include-tables` and `exclude-tables` options. + +```bash +paracelsus graph example_app.models.base:Base \ + --import-module "example_app.models.*" \ + --exclude-tables "^com.*" +``` + ### Specify Column Sort Order By default Paracelsus will sort the columns in all models such as primary keys are first, foreign keys are next and all other diff --git a/paracelsus/cli.py b/paracelsus/cli.py index 0cf7856..554e634 100644 --- a/paracelsus/cli.py +++ b/paracelsus/cli.py @@ -57,11 +57,11 @@ def graph( ] = [], exclude_tables: Annotated[ List[str], - typer.Option(help="List of tables that are excluded from the graph"), + typer.Option(help="List of tables or regular expression patterns for tables that are excluded from the graph"), ] = [], include_tables: Annotated[ List[str], - typer.Option(help="List of tables that are included in the graph"), + typer.Option(help="List of tables or regular expression patterns for tables that are included in the graph"), ] = [], python_dir: Annotated[ List[Path],