Skip to content

Commit

Permalink
Add --version
Browse files Browse the repository at this point in the history
Fixes #15
  • Loading branch information
pmav99 committed May 15, 2023
1 parent ffed845 commit ae91dbd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions inspectds/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import enum
import warnings
from importlib.metadata import version
from pathlib import Path
from typing import Annotated
from typing import Any
Expand Down Expand Up @@ -102,6 +103,12 @@ def infer_dataset_type(path: Path) -> DATASET_TYPE:
return dataset_type


def version_callback(value: bool) -> None:
if value:
typer.echo(f"inspectds version: {version('inspectds')}")
raise typer.Exit(code=0)


app = typer.Typer(
add_completion=False,
add_help_option=True,
Expand All @@ -121,6 +128,7 @@ def inspect_dataset(
variable_attributes: Annotated[bool, typer.Option(help="Whether to include the variable attributes in the output")] = False,
global_attributes: Annotated[bool, typer.Option(help="Whether to include the global attributes in the output")] =False,
full: Annotated[bool, typer.Option(help="Display full output. Overrides any other option")] = False,
version: Annotated[bool, typer.Option("--version", help="Display the version", callback=version_callback, is_eager=True)] = False,
# fmt: on
) -> int:
if dataset_type == DATASET_TYPE.AUTO:
Expand Down

0 comments on commit ae91dbd

Please sign in to comment.