Skip to content

Commit 6452e47

Browse files
authored
Merge pull request #45 from vertti/version-flag
Version flag
2 parents 0211207 + 8f2dbcc commit 6452e47

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "lazy-ecs"
3-
version = "0.7.3"
3+
version = "0.7.4"
44
description = "A CLI tool for working with AWS services"
55
readme = "README.md"
66
authors = [

src/lazy_ecs/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import argparse
2+
from importlib.metadata import PackageNotFoundError, version
23
from typing import TYPE_CHECKING
34

45
import boto3
@@ -15,12 +16,18 @@
1516
from .core.app import navigate_clusters
1617
from .ui import ECSNavigator
1718

19+
try:
20+
__version__ = version("lazy-ecs")
21+
except PackageNotFoundError:
22+
__version__ = "dev"
23+
1824
console = Console()
1925

2026

2127
def main() -> None:
2228
"""Interactive AWS ECS navigation tool."""
2329
parser = argparse.ArgumentParser(description="Interactive AWS ECS cluster navigator")
30+
parser.add_argument("--version", action="version", version=f"lazy-ecs {__version__}")
2431
parser.add_argument("--profile", help="AWS profile to use for authentication", type=str, default=None)
2532
args = parser.parse_args()
2633

tests/test_cli.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import sys
22
from unittest.mock import Mock, patch
33

4+
import pytest
5+
46
from lazy_ecs import _create_aws_client, main
57

68

@@ -133,3 +135,10 @@ def test_create_aws_client_with_profile():
133135
assert args[0] == "ecs"
134136
assert "config" in kwargs
135137
assert result == mock_client
138+
139+
140+
def test_version_flag():
141+
with patch.object(sys, "argv", ["lazy-ecs", "--version"]):
142+
with pytest.raises(SystemExit) as exc_info:
143+
main()
144+
assert exc_info.value.code == 0

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)