Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade typer to support union types #533

Merged
merged 7 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/docs/user/references/cli-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $ kpops clean [OPTIONS] PIPELINE_PATHS...
* `--dotenv FILE`: Path to dotenv file. Multiple files can be provided. The files will be loaded in order, with each file overriding the previous one. [env var: KPOPS_DOTENV_PATH]
* `--config DIRECTORY`: Path to the dir containing config.yaml files [env var: KPOPS_CONFIG_PATH; default: .]
* `--steps TEXT`: Comma separated list of steps to apply the command on [env var: KPOPS_PIPELINE_STEPS]
* `--filter-type [include|exclude]`: Whether the --steps option should include/exclude the steps [default: FilterType.INCLUDE]
* `--filter-type [include|exclude]`: Whether the --steps option should include/exclude the steps [default: include]
* `--environment TEXT`: The environment you want to generate and deploy the pipeline to. Suffix your environment files with this value (e.g. defaults_development.yaml for environment=development). [env var: KPOPS_ENVIRONMENT]
* `--dry-run / --execute`: Whether to dry run the command or execute it [default: dry-run]
* `--verbose / --no-verbose`: Enable verbose printing [default: no-verbose]
Expand All @@ -69,7 +69,7 @@ $ kpops deploy [OPTIONS] PIPELINE_PATHS...
* `--dotenv FILE`: Path to dotenv file. Multiple files can be provided. The files will be loaded in order, with each file overriding the previous one. [env var: KPOPS_DOTENV_PATH]
* `--config DIRECTORY`: Path to the dir containing config.yaml files [env var: KPOPS_CONFIG_PATH; default: .]
* `--steps TEXT`: Comma separated list of steps to apply the command on [env var: KPOPS_PIPELINE_STEPS]
* `--filter-type [include|exclude]`: Whether the --steps option should include/exclude the steps [default: FilterType.INCLUDE]
* `--filter-type [include|exclude]`: Whether the --steps option should include/exclude the steps [default: include]
* `--environment TEXT`: The environment you want to generate and deploy the pipeline to. Suffix your environment files with this value (e.g. defaults_development.yaml for environment=development). [env var: KPOPS_ENVIRONMENT]
* `--dry-run / --execute`: Whether to dry run the command or execute it [default: dry-run]
* `--verbose / --no-verbose`: Enable verbose printing [default: no-verbose]
Expand All @@ -95,7 +95,7 @@ $ kpops destroy [OPTIONS] PIPELINE_PATHS...
* `--dotenv FILE`: Path to dotenv file. Multiple files can be provided. The files will be loaded in order, with each file overriding the previous one. [env var: KPOPS_DOTENV_PATH]
* `--config DIRECTORY`: Path to the dir containing config.yaml files [env var: KPOPS_CONFIG_PATH; default: .]
* `--steps TEXT`: Comma separated list of steps to apply the command on [env var: KPOPS_PIPELINE_STEPS]
* `--filter-type [include|exclude]`: Whether the --steps option should include/exclude the steps [default: FilterType.INCLUDE]
* `--filter-type [include|exclude]`: Whether the --steps option should include/exclude the steps [default: include]
* `--environment TEXT`: The environment you want to generate and deploy the pipeline to. Suffix your environment files with this value (e.g. defaults_development.yaml for environment=development). [env var: KPOPS_ENVIRONMENT]
* `--dry-run / --execute`: Whether to dry run the command or execute it [default: dry-run]
* `--verbose / --no-verbose`: Enable verbose printing [default: no-verbose]
Expand All @@ -121,7 +121,7 @@ $ kpops generate [OPTIONS] PIPELINE_PATHS...
* `--dotenv FILE`: Path to dotenv file. Multiple files can be provided. The files will be loaded in order, with each file overriding the previous one. [env var: KPOPS_DOTENV_PATH]
* `--config DIRECTORY`: Path to the dir containing config.yaml files [env var: KPOPS_CONFIG_PATH; default: .]
* `--steps TEXT`: Comma separated list of steps to apply the command on [env var: KPOPS_PIPELINE_STEPS]
* `--filter-type [include|exclude]`: Whether the --steps option should include/exclude the steps [default: FilterType.INCLUDE]
* `--filter-type [include|exclude]`: Whether the --steps option should include/exclude the steps [default: include]
* `--environment TEXT`: The environment you want to generate and deploy the pipeline to. Suffix your environment files with this value (e.g. defaults_development.yaml for environment=development). [env var: KPOPS_ENVIRONMENT]
* `--verbose / --no-verbose`: Enable verbose printing [default: no-verbose]
* `--help`: Show this message and exit.
Expand Down Expand Up @@ -164,7 +164,7 @@ $ kpops manifest [OPTIONS] PIPELINE_PATHS...
* `--dotenv FILE`: Path to dotenv file. Multiple files can be provided. The files will be loaded in order, with each file overriding the previous one. [env var: KPOPS_DOTENV_PATH]
* `--config DIRECTORY`: Path to the dir containing config.yaml files [env var: KPOPS_CONFIG_PATH; default: .]
* `--steps TEXT`: Comma separated list of steps to apply the command on [env var: KPOPS_PIPELINE_STEPS]
* `--filter-type [include|exclude]`: Whether the --steps option should include/exclude the steps [default: FilterType.INCLUDE]
* `--filter-type [include|exclude]`: Whether the --steps option should include/exclude the steps [default: include]
* `--environment TEXT`: The environment you want to generate and deploy the pipeline to. Suffix your environment files with this value (e.g. defaults_development.yaml for environment=development). [env var: KPOPS_ENVIRONMENT]
* `--verbose / --no-verbose`: Enable verbose printing [default: no-verbose]
* `--help`: Show this message and exit.
Expand All @@ -188,7 +188,7 @@ $ kpops reset [OPTIONS] PIPELINE_PATHS...
* `--dotenv FILE`: Path to dotenv file. Multiple files can be provided. The files will be loaded in order, with each file overriding the previous one. [env var: KPOPS_DOTENV_PATH]
* `--config DIRECTORY`: Path to the dir containing config.yaml files [env var: KPOPS_CONFIG_PATH; default: .]
* `--steps TEXT`: Comma separated list of steps to apply the command on [env var: KPOPS_PIPELINE_STEPS]
* `--filter-type [include|exclude]`: Whether the --steps option should include/exclude the steps [default: FilterType.INCLUDE]
* `--filter-type [include|exclude]`: Whether the --steps option should include/exclude the steps [default: include]
* `--environment TEXT`: The environment you want to generate and deploy the pipeline to. Suffix your environment files with this value (e.g. defaults_development.yaml for environment=development). [env var: KPOPS_ENVIRONMENT]
* `--dry-run / --execute`: Whether to dry run the command or execute it [default: dry-run]
* `--verbose / --no-verbose`: Enable verbose printing [default: no-verbose]
Expand Down
45 changes: 22 additions & 23 deletions kpops/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

from pathlib import Path
from typing import Optional

import typer

Expand All @@ -27,7 +26,7 @@

app = typer.Typer(pretty_exceptions_enable=False)

DOTENV_PATH_OPTION: Optional[list[Path]] = typer.Option(
DOTENV_PATH_OPTION: list[Path] | None = typer.Option(
default=None,
exists=True,
dir_okay=False,
Expand Down Expand Up @@ -74,7 +73,7 @@
help="Whether to include non-required settings in the generated 'config.yaml'",
)

PIPELINE_STEPS: Optional[str] = typer.Option(
PIPELINE_STEPS: str | None = typer.Option(
default=None,
envvar=f"{ENV_PREFIX}PIPELINE_STEPS",
help="Comma separated list of steps to apply the command on",
Expand All @@ -100,8 +99,8 @@
help="Whether the --steps option should include/exclude the steps",
)

OUTPUT_OPTION = typer.Option(True, help="Enable output printing")
VERBOSE_OPTION = typer.Option(False, help="Enable verbose printing")
OUTPUT_OPTION: bool = typer.Option(True, help="Enable output printing")
VERBOSE_OPTION: bool = typer.Option(False, help="Enable verbose printing")

ENVIRONMENT: str | None = typer.Option(
default=None,
Expand Down Expand Up @@ -161,11 +160,11 @@ def schema(
)
def generate(
pipeline_paths: list[Path] = PIPELINE_PATHS_ARG,
dotenv: Optional[list[Path]] = DOTENV_PATH_OPTION,
dotenv: list[Path] | None = DOTENV_PATH_OPTION,
config: Path = CONFIG_PATH_OPTION,
steps: Optional[str] = PIPELINE_STEPS,
steps: str | None = PIPELINE_STEPS,
filter_type: FilterType = FILTER_TYPE,
environment: Optional[str] = ENVIRONMENT,
environment: str | None = ENVIRONMENT,
verbose: bool = VERBOSE_OPTION,
):
for pipeline_file_path in collect_pipeline_paths(pipeline_paths):
Expand All @@ -187,11 +186,11 @@ def generate(
)
def manifest(
pipeline_paths: list[Path] = PIPELINE_PATHS_ARG,
dotenv: Optional[list[Path]] = DOTENV_PATH_OPTION,
dotenv: list[Path] | None = DOTENV_PATH_OPTION,
config: Path = CONFIG_PATH_OPTION,
steps: Optional[str] = PIPELINE_STEPS,
steps: str | None = PIPELINE_STEPS,
filter_type: FilterType = FILTER_TYPE,
environment: Optional[str] = ENVIRONMENT,
environment: str | None = ENVIRONMENT,
verbose: bool = VERBOSE_OPTION,
):
for pipeline_file_path in collect_pipeline_paths(pipeline_paths):
Expand All @@ -212,11 +211,11 @@ def manifest(
@app.command(help="Deploy pipeline steps")
def deploy(
pipeline_paths: list[Path] = PIPELINE_PATHS_ARG,
dotenv: Optional[list[Path]] = DOTENV_PATH_OPTION,
dotenv: list[Path] | None = DOTENV_PATH_OPTION,
config: Path = CONFIG_PATH_OPTION,
steps: Optional[str] = PIPELINE_STEPS,
steps: str | None = PIPELINE_STEPS,
filter_type: FilterType = FILTER_TYPE,
environment: Optional[str] = ENVIRONMENT,
environment: str | None = ENVIRONMENT,
dry_run: bool = DRY_RUN,
verbose: bool = VERBOSE_OPTION,
parallel: bool = PARALLEL,
Expand All @@ -238,11 +237,11 @@ def deploy(
@app.command(help="Destroy pipeline steps")
def destroy(
pipeline_paths: list[Path] = PIPELINE_PATHS_ARG,
dotenv: Optional[list[Path]] = DOTENV_PATH_OPTION,
dotenv: list[Path] | None = DOTENV_PATH_OPTION,
config: Path = CONFIG_PATH_OPTION,
steps: Optional[str] = PIPELINE_STEPS,
steps: str | None = PIPELINE_STEPS,
filter_type: FilterType = FILTER_TYPE,
environment: Optional[str] = ENVIRONMENT,
environment: str | None = ENVIRONMENT,
dry_run: bool = DRY_RUN,
verbose: bool = VERBOSE_OPTION,
parallel: bool = PARALLEL,
Expand All @@ -264,11 +263,11 @@ def destroy(
@app.command(help="Reset pipeline steps")
def reset(
pipeline_paths: list[Path] = PIPELINE_PATHS_ARG,
dotenv: Optional[list[Path]] = DOTENV_PATH_OPTION,
dotenv: list[Path] | None = DOTENV_PATH_OPTION,
config: Path = CONFIG_PATH_OPTION,
steps: Optional[str] = PIPELINE_STEPS,
steps: str | None = PIPELINE_STEPS,
filter_type: FilterType = FILTER_TYPE,
environment: Optional[str] = ENVIRONMENT,
environment: str | None = ENVIRONMENT,
dry_run: bool = DRY_RUN,
verbose: bool = VERBOSE_OPTION,
parallel: bool = PARALLEL,
Expand All @@ -290,11 +289,11 @@ def reset(
@app.command(help="Clean pipeline steps")
def clean(
pipeline_paths: list[Path] = PIPELINE_PATHS_ARG,
dotenv: Optional[list[Path]] = DOTENV_PATH_OPTION,
dotenv: list[Path] | None = DOTENV_PATH_OPTION,
config: Path = CONFIG_PATH_OPTION,
steps: Optional[str] = PIPELINE_STEPS,
steps: str | None = PIPELINE_STEPS,
filter_type: FilterType = FILTER_TYPE,
environment: Optional[str] = ENVIRONMENT,
environment: str | None = ENVIRONMENT,
dry_run: bool = DRY_RUN,
verbose: bool = VERBOSE_OPTION,
parallel: bool = PARALLEL,
Expand Down
51 changes: 20 additions & 31 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading