This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-releases-client.git


The following commit(s) were added to refs/heads/main by this push:
     new 33a9e57  Add a simple command line test
33a9e57 is described below

commit 33a9e57337480a608b6a4b0ca4404af5af567d1d
Author: Sean B. Palmer <[email protected]>
AuthorDate: Thu Jul 10 14:46:03 2025 +0100

    Add a simple command line test
---
 pyproject.toml            |  4 ++--
 src/atrclient/__init__.py |  6 ++----
 src/atrclient/client.py   | 30 ++++++++++++++++--------------
 tests/test_all.py         |  8 ++++++++
 uv.lock                   |  4 ++--
 5 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/pyproject.toml b/pyproject.toml
index 99806ea..1c45dc6 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -11,7 +11,7 @@ build-backend = "hatchling.build"
 
 [project]
 name            = "apache-trusted-releases"
-version         = "0.20250710.1328"
+version         = "0.20250710.1345"
 description     = "ATR CLI and Python API"
 readme          = "README.md"
 requires-python = ">=3.13"
@@ -48,4 +48,4 @@ atr = "atrclient.client:main"
 packages = ["src/atrclient"]
 
 [tool.uv]
-exclude-newer = "2025-07-10T13:28:00Z"
+exclude-newer = "2025-07-10T13:45:00Z"
diff --git a/src/atrclient/__init__.py b/src/atrclient/__init__.py
index f588bc2..5b64ee1 100644
--- a/src/atrclient/__init__.py
+++ b/src/atrclient/__init__.py
@@ -1,13 +1,11 @@
-import importlib.metadata
 from typing import Final
 
 import atrclient.client
 
+VERSION = atrclient.client.VERSION
 main = atrclient.client.main
-version = importlib.metadata.version("apache-trusted-releases")
 
-__all__: Final[list[str]] = ["main", "version"]
+__all__: Final[list[str]] = ["VERSION", "main"]
 
 del Final
 del atrclient
-del importlib
diff --git a/src/atrclient/client.py b/src/atrclient/client.py
index b33c399..6f67f7e 100755
--- a/src/atrclient/client.py
+++ b/src/atrclient/client.py
@@ -52,6 +52,7 @@ DEV: cyclopts.App = cyclopts.App(name="dev", help="Developer 
operations.")
 JWT: cyclopts.App = cyclopts.App(name="jwt", help="JWT operations.")
 LOGGER = logging.getLogger(__name__)
 RELEASE: cyclopts.App = cyclopts.App(name="release", help="Release 
operations.")
+VERSION: str = metadata.version("apache-trusted-releases")
 VOTE: cyclopts.App = cyclopts.App(name="vote", help="Vote operations.")
 YAML_DEFAULTS: dict[str, Any] = {"asf": {}, "atr": {}, "tokens": {}}
 YAML_SCHEMA: strictyaml.Map = strictyaml.Map(
@@ -71,13 +72,6 @@ YAML_SCHEMA: strictyaml.Map = strictyaml.Map(
     }
 )
 
-APP.command(CHECKS)
-APP.command(CONFIG)
-APP.command(DEV)
-APP.command(JWT)
-APP.command(RELEASE)
-APP.command(VOTE)
-
 
 @CHECKS.command(name="exceptions", help="Get check exceptions for a release 
revision.")
 def app_checks_exceptions(
@@ -371,12 +365,6 @@ def app_upload(project: str, version: str, path: str, 
filepath: str) -> None:
     print(result)
 
 
[email protected](name="version", help="Show the version of the client.")
-def app_version() -> None:
-    version = metadata.version("apache-trusted-releases")
-    print(version)
-
-
 @VOTE.command(name="start", help="Start a vote.")
 def app_vote_start(
     project: str,
@@ -705,7 +693,12 @@ def iso_to_human(ts: str) -> str:
 def main() -> None:
     signal.signal(signal.SIGPIPE, signal.SIG_DFL)
     logging.basicConfig(level=logging.INFO, format="%(message)s")
-    APP()
+    subcommands_register(APP)
+    APP.version = VERSION
+    # if "PYTEST_CURRENT_TEST" in os.environ:
+    #     # "Cyclopts application invoked without tokens"
+    #     pass
+    APP(sys.argv[1:])
 
 
 def releases_display(result: dict[str, Any]) -> None:
@@ -737,6 +730,15 @@ def releases_display(result: dict[str, Any]) -> None:
         print(f"  {version:<24} {latest:<7} {phase_short:<11} 
{created_formatted}")
 
 
+def subcommands_register(app: cyclopts.App) -> None:
+    app.command(CHECKS)
+    app.command(CONFIG)
+    app.command(DEV)
+    app.command(JWT)
+    app.command(RELEASE)
+    app.command(VOTE)
+
+
 def timestamp_format(ts: int | str | None) -> str | None:
     if ts is None:
         return None
diff --git a/tests/test_all.py b/tests/test_all.py
index f421b3d..16119f3 100755
--- a/tests/test_all.py
+++ b/tests/test_all.py
@@ -25,6 +25,7 @@ from typing import Any
 
 import aioresponses
 import pytest
+import pytest_console_scripts
 
 
 def test_app_checks_status_non_draft_phase(
@@ -174,6 +175,13 @@ def test_app_set_show(
     assert capsys.readouterr().out == "example.invalid\n"
 
 
+def test_cli_version(script_runner: pytest_console_scripts.ScriptRunner) -> 
None:
+    result = script_runner.run(["atr", "--version"])
+    assert result.returncode == 0
+    assert result.stdout == f"{client.VERSION}\n"
+    assert result.stderr == ""
+
+
 def test_config_set_get_roundtrip() -> None:
     config: dict[str, Any] = {}
     client.config_set(config, ["abc", "pqr"], 123)
diff --git a/uv.lock b/uv.lock
index 6ef3f61..bbb5e38 100644
--- a/uv.lock
+++ b/uv.lock
@@ -2,7 +2,7 @@ version = 1
 requires-python = ">=3.13"
 
 [options]
-exclude-newer = "2025-07-10T13:28:00Z"
+exclude-newer = "2025-07-10T13:45:00Z"
 
 [[package]]
 name = "aiohappyeyeballs"
@@ -74,7 +74,7 @@ wheels = [
 
 [[package]]
 name = "apache-trusted-releases"
-version = "0.20250710.1328"
+version = "0.20250710.1345"
 source = { editable = "." }
 dependencies = [
     { name = "aiohttp" },


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to