Skip to content

Commit

Permalink
feat(cli): Implement --version flag to CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab committed Dec 23, 2023
1 parent 9b2179a commit 205343b
Showing 1 changed file with 23 additions and 0 deletions.
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

0 comments on commit 205343b

Please sign in to comment.