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

feat(cli): Implement --version flag to CLI #11

Merged
merged 1 commit into from
Dec 23, 2023
Merged
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
23 changes: 23 additions & 0 deletions src/envers/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,36 @@

import typer

from typer import Context, Option
from typing_extensions import Annotated

from envers import __version__
from envers.core import Envers

app = typer.Typer()


@app.callback(invoke_without_command=True)
def main(
ctx: Context,
version: bool = Option(
None,
"--version",
"-v",
is_flag=True,
help="Show the version and exit.",
),
) -> None:
"""Process envers for specific flags, otherwise show the help menu."""
if version:
typer.echo(f"Version: {__version__}")
raise typer.Exit()

if ctx.invoked_subcommand is None:
typer.echo(ctx.get_help())
raise typer.Exit(0)


@app.command()
def init(path: str = ".") -> None:
"""
Expand Down