Skip to content

Commit

Permalink
Added a command that prints installed KPOps version
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonsadowski3 committed Apr 26, 2023
1 parent 3b5aa5b commit cdce502
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kpops/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import importlib.metadata

__version__ = importlib.metadata.version("kpops")
16 changes: 16 additions & 0 deletions kpops/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import typer

from kpops import __version__
from kpops.cli.custom_formatter import CustomFormatter
from kpops.cli.pipeline_config import ENV_PREFIX, PipelineConfig
from kpops.cli.registry import Registry
Expand Down Expand Up @@ -345,5 +346,20 @@ def clean(
component.clean(dry_run)


def version_callback(show_version: bool) -> None:
if show_version:
typer.echo(f"KPOps Version: {__version__}")
raise typer.Exit()


@app.callback()
def main(
version: bool = typer.Option(
False, "--version", "-V", callback=version_callback, is_eager=True
),
):
return


if __name__ == "__main__":
app()

0 comments on commit cdce502

Please sign in to comment.