Skip to content

Commit

Permalink
Add --version option
Browse files Browse the repository at this point in the history
  • Loading branch information
jlantz committed Oct 30, 2024
1 parent a1cac13 commit 9e273a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions d2x/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@
import pdb
from d2x.base.types import OutputFormat, OutputFormatType, CLIOptions
from typing import Optional
from importlib.metadata import version, PackageNotFoundError

# Disable rich_click's syntax highlighting
click.SHOW_ARGUMENTS = False
click.SHOW_METAVARS_COLUMN = False
click.SHOW_OPTIONS = False

try:
VERSION = version("d2x")
except PackageNotFoundError:
VERSION = "dev"


def common_options(func):
"""Decorator to add common options to all commands."""
Expand All @@ -26,6 +32,7 @@ def common_options(func):


@click.group(name="d2x")
@click.version_option(version=VERSION, prog_name="d2x")
def d2x_cli():
"""D2X CLI main command group"""
pass
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ pip-tools = "^7.4.1"
[tool.poetry.scripts]
d2x = "d2x.cli.main:d2x_cli"

[project]
name = "d2x"

[project.scripts]
d2x = "d2x.cli:d2x_cli"

Expand Down

0 comments on commit 9e273a9

Please sign in to comment.