From ee4e682cfc1784f6d00bea0f5d37b4a91d700de1 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Sat, 17 Jan 2026 23:43:14 +0000 Subject: [PATCH] Add --version --- .gitignore | 1 + fastapi_vue_setup.py | 10 ++++++++++ pyproject.toml | 3 +++ 3 files changed, 14 insertions(+) diff --git a/.gitignore b/.gitignore index 16839bf..b832ab5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *.lock __pycache__/ dist/ +/_version.py diff --git a/fastapi_vue_setup.py b/fastapi_vue_setup.py index b0ac729..3d65624 100644 --- a/fastapi_vue_setup.py +++ b/fastapi_vue_setup.py @@ -21,6 +21,11 @@ from textwrap import indent import tomli_w +try: + from _version import __version__ +except ImportError: + __version__ = "0.0.0+unknown" + # Template directory TEMPLATE_DIR = Path(__file__).parent / "template" @@ -896,6 +901,11 @@ Examples: parser.add_argument( "--dry-run", action="store_true", help="Show what would be done" ) + parser.add_argument( + "--version", + action="version", + version=f"%(prog)s {__version__}", + ) args = parser.parse_args() diff --git a/pyproject.toml b/pyproject.toml index c3e3d06..139c36a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,9 @@ fastapi-vue-setup = "fastapi_vue_setup:main" [tool.hatch.version] source = "vcs" +[tool.hatch.build.hooks.vcs] +version-file = "_version.py" + [tool.hatch.build.targets.wheel] include = ["fastapi_vue_setup.py", "template/**/*", "_version.py"]