From 0fe22e972a44e4bc947aafdc482b32ee7ad286a3 Mon Sep 17 00:00:00 2001 From: Salomon Popp Date: Thu, 27 Jun 2024 00:19:20 +0200 Subject: [PATCH] Improve CLI help --- docs/docs/user/references/cli-commands.md | 7 +++++-- kpops/api/file_type.py | 5 +++++ kpops/cli/main.py | 16 ++++++++++------ kpops/cli/utils.py | 4 +--- tests/components/test_base_defaults_component.py | 6 +----- tests/pipeline/test_generate.py | 4 +--- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/docs/docs/user/references/cli-commands.md b/docs/docs/user/references/cli-commands.md index 173032d65..0a187f139 100644 --- a/docs/docs/user/references/cli-commands.md +++ b/docs/docs/user/references/cli-commands.md @@ -215,12 +215,15 @@ $ kpops schema [OPTIONS] SCOPE:{pipeline|defaults|config} - pipeline: Schema of PipelineComponents. Includes the built-in KPOps components by default. To include custom components, provide components module in config. + - pipeline: Schema of PipelineComponents for KPOps pipeline.yaml + - defaults: Schema of PipelineComponents for KPOps defaults.yaml + + - config: Schema of KpopsConfig. [required] + - config: Schema for KPOps config.yaml [required] **Options**: diff --git a/kpops/api/file_type.py b/kpops/api/file_type.py index c08fce987..3e170be96 100644 --- a/kpops/api/file_type.py +++ b/kpops/api/file_type.py @@ -33,3 +33,8 @@ def as_yaml_file(self, prefix: str = "", suffix: str = "") -> str: 'pre_pipeline_suf.yaml' """ return prefix + self.value + suffix + FILE_EXTENSION + + +PIPELINE_YAML = KpopsFileType.PIPELINE.as_yaml_file() +DEFAULTS_YAML = KpopsFileType.DEFAULTS.as_yaml_file() +CONFIG_YAML = KpopsFileType.CONFIG.as_yaml_file() diff --git a/kpops/cli/main.py b/kpops/cli/main.py index 3e669df54..d33712b3e 100644 --- a/kpops/cli/main.py +++ b/kpops/cli/main.py @@ -6,9 +6,11 @@ import typer import kpops.api as kpops -from kpops.api.file_type import KpopsFileType +from kpops.api.file_type import CONFIG_YAML, DEFAULTS_YAML, PIPELINE_YAML, KpopsFileType from kpops.api.options import FilterType -from kpops.cli.utils import collect_pipeline_paths +from kpops.cli.utils import ( + collect_pipeline_paths, +) from kpops.config import ENV_PREFIX from kpops.utils.gen_schema import ( gen_config_schema, @@ -128,12 +130,14 @@ def schema( scope: KpopsFileType = typer.Argument( ..., show_default=False, - help=""" + help=f""" Scope of the generated schema \n\n\n - pipeline: Schema of PipelineComponents. Includes the built-in KPOps components by default. To include custom components, provide components module in config. - \n\n\n - config: Schema of KpopsConfig.""", + - {KpopsFileType.PIPELINE.value}: Schema of PipelineComponents for KPOps {PIPELINE_YAML} + \n\n + - {KpopsFileType.DEFAULTS.value}: Schema of PipelineComponents for KPOps {DEFAULTS_YAML} + \n\n + - {KpopsFileType.CONFIG.value}: Schema for KPOps {CONFIG_YAML}""", ), ) -> None: match scope: diff --git a/kpops/cli/utils.py b/kpops/cli/utils.py index f4a04bcbb..16a8af563 100644 --- a/kpops/cli/utils.py +++ b/kpops/cli/utils.py @@ -3,9 +3,7 @@ from collections.abc import Iterable, Iterator from pathlib import Path -from kpops.api.file_type import KpopsFileType - -PIPELINE_YAML = KpopsFileType.PIPELINE.as_yaml_file() +from kpops.api.file_type import PIPELINE_YAML def collect_pipeline_paths(pipeline_paths: Iterable[Path]) -> Iterator[Path]: diff --git a/tests/components/test_base_defaults_component.py b/tests/components/test_base_defaults_component.py index ab21ef68e..f8fe12eec 100644 --- a/tests/components/test_base_defaults_component.py +++ b/tests/components/test_base_defaults_component.py @@ -6,7 +6,7 @@ import pydantic import pytest -from kpops.api.file_type import KpopsFileType +from kpops.api.file_type import DEFAULTS_YAML, PIPELINE_YAML, KpopsFileType from kpops.component_handlers import ComponentHandlers from kpops.components.base_components.base_defaults_component import ( BaseDefaultsComponent, @@ -17,10 +17,6 @@ from kpops.utils.environment import ENV from tests.components import PIPELINE_BASE_DIR, RESOURCES_PATH -PIPELINE_YAML = KpopsFileType.PIPELINE.as_yaml_file() - -DEFAULTS_YAML = KpopsFileType.DEFAULTS.as_yaml_file() - class Parent(BaseDefaultsComponent): __test__ = False diff --git a/tests/pipeline/test_generate.py b/tests/pipeline/test_generate.py index 58209e384..07da70082 100644 --- a/tests/pipeline/test_generate.py +++ b/tests/pipeline/test_generate.py @@ -11,13 +11,11 @@ import kpops.api as kpops from kpops.api.exception import ParsingException, ValidationError -from kpops.api.file_type import KpopsFileType +from kpops.api.file_type import PIPELINE_YAML, KpopsFileType from kpops.cli.main import FilterType, app from kpops.components.base_components.kafka_connector import KafkaSinkConnector from kpops.components.base_components.pipeline_component import PipelineComponent -PIPELINE_YAML = KpopsFileType.PIPELINE.as_yaml_file() - runner = CliRunner() RESOURCE_PATH = Path(__file__).parent / "resources"