diff --git a/pyproject.toml b/pyproject.toml index ea100b3..515b3f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "lazy-ecs" -version = "0.7.3" +version = "0.7.4" description = "A CLI tool for working with AWS services" readme = "README.md" authors = [ diff --git a/src/lazy_ecs/__init__.py b/src/lazy_ecs/__init__.py index 58b5a80..7f4d219 100644 --- a/src/lazy_ecs/__init__.py +++ b/src/lazy_ecs/__init__.py @@ -1,4 +1,5 @@ import argparse +from importlib.metadata import PackageNotFoundError, version from typing import TYPE_CHECKING import boto3 @@ -15,12 +16,18 @@ from .core.app import navigate_clusters from .ui import ECSNavigator +try: + __version__ = version("lazy-ecs") +except PackageNotFoundError: + __version__ = "dev" + console = Console() def main() -> None: """Interactive AWS ECS navigation tool.""" parser = argparse.ArgumentParser(description="Interactive AWS ECS cluster navigator") + parser.add_argument("--version", action="version", version=f"lazy-ecs {__version__}") parser.add_argument("--profile", help="AWS profile to use for authentication", type=str, default=None) args = parser.parse_args() diff --git a/tests/test_cli.py b/tests/test_cli.py index d84e62c..ec8bdb5 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,6 +1,8 @@ import sys from unittest.mock import Mock, patch +import pytest + from lazy_ecs import _create_aws_client, main @@ -133,3 +135,10 @@ def test_create_aws_client_with_profile(): assert args[0] == "ecs" assert "config" in kwargs assert result == mock_client + + +def test_version_flag(): + with patch.object(sys, "argv", ["lazy-ecs", "--version"]): + with pytest.raises(SystemExit) as exc_info: + main() + assert exc_info.value.code == 0 diff --git a/uv.lock b/uv.lock index 2e89a5c..bd2422d 100644 --- a/uv.lock +++ b/uv.lock @@ -404,7 +404,7 @@ wheels = [ [[package]] name = "lazy-ecs" -version = "0.7.3" +version = "0.7.4" source = { editable = "." } dependencies = [ { name = "boto3" },