Skip to content

Commit 709b20b

Browse files
raxhvldanceratopz
andauthored
✨ feat(cli): eest info (#1621)
Co-authored-by: danceratopz <danceratopz@gmail.com>
1 parent a6d2310 commit 709b20b

File tree

5 files changed

+65
-4
lines changed

5 files changed

+65
-4
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ The output behavior of `fill` has changed ([#1608](https://github.com/ethereum/e
3030

3131
- ✨ Added the [EIP checklist template](https://eest.ethereum.org/main/writing_tests/checklist_templates/eip_testing_checklist_template/) that serves as a reference to achieve better coverage when implementing tests for new EIPs ([#1327](https://github.com/ethereum/execution-spec-tests/pull/1327)).
3232
- ✨ Added [Post-Mortems of Missed Test Scenarios](https://eest.ethereum.org/main/writing_tests/post_mortems/) to the documentation that serves as a reference list of all cases that were missed during the test implementation phase of a new EIP, and includes the steps taken in order to prevent similar test cases to be missed in the future ([#1327](https://github.com/ethereum/execution-spec-tests/pull/1327)).
33+
- ✨ Added a new `eest` sub-command, `eest info`, to easily print a cloned EEST repository's version and the versions of relevant tools, e.g., `python`, `uv` ([#1621](https://github.com/ethereum/execution-spec-tests/pull/1621)).
3334

3435
### 🧪 Test Cases
3536

src/cli/eest/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import click
77

8-
from cli.eest.commands import clean
8+
from cli.eest.commands import clean, info
99
from cli.eest.make.cli import make
1010

1111

@@ -27,3 +27,4 @@ def eest():
2727
"""
2828
eest.add_command(make)
2929
eest.add_command(clean)
30+
eest.add_command(info)

src/cli/eest/commands/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"""
66

77
from .clean import clean
8+
from .info import info
89

9-
__all__ = ["clean"]
10+
__all__ = ["clean", "info"]

src/cli/eest/commands/info.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"""Command to display EEST and system information."""
2+
3+
import platform
4+
import subprocess
5+
import sys
6+
7+
import click
8+
9+
from config.app import AppConfig
10+
from ethereum_test_tools.utility.versioning import get_current_commit_hash_or_tag
11+
12+
13+
def run_command(command: list[str]) -> str:
14+
"""Run a CLI command and return its output."""
15+
try:
16+
result = subprocess.run(
17+
command,
18+
capture_output=True,
19+
text=True,
20+
check=True,
21+
)
22+
return result.stdout.strip()
23+
except (subprocess.SubprocessError, FileNotFoundError):
24+
return "unknown"
25+
26+
27+
def get_uv_version() -> str:
28+
"""Get the installed uv package manager version."""
29+
return run_command(["uv", "--version"])
30+
31+
32+
@click.command(name="info")
33+
def info():
34+
"""Display EEST and system information."""
35+
# Format headers
36+
title = click.style("EEST", fg="green", bold=True)
37+
38+
version = AppConfig().version
39+
40+
info_text = f"""
41+
{title} {click.style(f"v{version}", fg="blue", bold=True)}
42+
{"─" * 50}
43+
44+
Git commit: {click.style(get_current_commit_hash_or_tag(shorten_hash=True), fg="yellow")}
45+
Python: {click.style(platform.python_version(), fg="blue")}
46+
uv: {click.style(get_uv_version(), fg="magenta")}
47+
OS: {click.style(f"{platform.system()} {platform.release()}", fg="cyan")}
48+
Platform: {click.style(platform.machine(), fg="cyan")}
49+
Python Path: {click.style(sys.executable, dim=True)}
50+
"""
51+
52+
click.echo(info_text)

src/config/app.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@
99

1010
from pydantic import BaseModel
1111

12+
import pytest_plugins.consume.releases as releases
13+
1214

1315
class AppConfig(BaseModel):
1416
"""A class for accessing documentation-related configurations."""
1517

16-
version: str = "3.0.0"
17-
"""The version of the application framework."""
18+
@property
19+
def version(self) -> str:
20+
"""Get the current version from releases."""
21+
spec = "stable@latest"
22+
release_url = releases.get_release_url(spec)
23+
return release_url.split("/v")[-1].split("/")[0]
1824

1925
DEFAULT_LOGS_DIR: Path = Path(__file__).resolve().parent.parent.parent / "logs"
2026
"""The default directory where log files are stored."""

0 commit comments

Comments
 (0)