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

Add kpops --version command #200

Merged
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
1 change: 1 addition & 0 deletions docs/docs/user/references/cli-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ $ kpops [OPTIONS] COMMAND [ARGS]...

**Options**:

* `-V, --version`: Print KPOps version
* `--install-completion`: Install completion for the current shell.
* `--show-completion`: Show completion for the current shell, to copy it or customize the installation.
* `--help`: Show this message and exit.
Expand Down
1 change: 1 addition & 0 deletions kpops/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "1.1.1"
21 changes: 21 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,25 @@ def clean(
component.clean(dry_run)


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


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


if __name__ == "__main__":
app()
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ mkdocs-glightbox = "^0.3.1"
mike = "^1.1.2"
typer-cli = "^0.0.13"

[tool.poetry_bumpversion.file."kpops/__init__.py"]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"