Skip to content

Commit

Permalink
Improve CLI help
Browse files Browse the repository at this point in the history
  • Loading branch information
disrupted committed Jun 26, 2024
1 parent d22e789 commit 0fe22e9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 19 deletions.
7 changes: 5 additions & 2 deletions docs/docs/user/references/cli-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**:

Expand Down
5 changes: 5 additions & 0 deletions kpops/api/file_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
16 changes: 10 additions & 6 deletions kpops/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions kpops/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
6 changes: 1 addition & 5 deletions tests/components/test_base_defaults_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions tests/pipeline/test_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 0fe22e9

Please sign in to comment.