Skip to content

Commit e77d99a

Browse files
committed
Support for version command
1 parent d4d3139 commit e77d99a

2 files changed

Lines changed: 81 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "specify-cli"
3-
version = "0.0.20"
3+
version = "0.0.21"
44
description = "Specify CLI, part of GitHub Spec Kit. A tool to bootstrap your projects for Spec-Driven Development (SDD)."
55
requires-python = ">=3.11"
66
dependencies = [

src/specify_cli/__init__.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,86 @@ def check():
11961196
if not any(agent_results.values()):
11971197
console.print("[dim]Tip: Install an AI assistant for the best experience[/dim]")
11981198

1199+
@app.command()
1200+
def version():
1201+
"""Display version and system information."""
1202+
import platform
1203+
import importlib.metadata
1204+
1205+
show_banner()
1206+
1207+
# Get CLI version from package metadata
1208+
cli_version = "unknown"
1209+
try:
1210+
cli_version = importlib.metadata.version("specify-cli")
1211+
except Exception:
1212+
# Fallback: try reading from pyproject.toml if running from source
1213+
try:
1214+
import tomllib
1215+
pyproject_path = Path(__file__).parent.parent.parent / "pyproject.toml"
1216+
if pyproject_path.exists():
1217+
with open(pyproject_path, "rb") as f:
1218+
data = tomllib.load(f)
1219+
cli_version = data.get("project", {}).get("version", "unknown")
1220+
except Exception:
1221+
pass
1222+
1223+
# Fetch latest template release version
1224+
repo_owner = "github"
1225+
repo_name = "spec-kit"
1226+
api_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/releases/latest"
1227+
1228+
template_version = "unknown"
1229+
release_date = "unknown"
1230+
1231+
try:
1232+
response = client.get(
1233+
api_url,
1234+
timeout=10,
1235+
follow_redirects=True,
1236+
headers=_github_auth_headers(),
1237+
)
1238+
if response.status_code == 200:
1239+
release_data = response.json()
1240+
template_version = release_data.get("tag_name", "unknown")
1241+
# Remove 'v' prefix if present
1242+
if template_version != "unknown" and template_version.startswith("v"):
1243+
template_version = template_version[1:]
1244+
release_date = release_data.get("published_at", "unknown")
1245+
if release_date != "unknown":
1246+
# Format the date nicely
1247+
from datetime import datetime
1248+
try:
1249+
dt = datetime.fromisoformat(release_date.replace('Z', '+00:00'))
1250+
release_date = dt.strftime("%Y-%m-%d")
1251+
except Exception:
1252+
pass
1253+
except Exception:
1254+
pass
1255+
1256+
info_table = Table(show_header=False, box=None, padding=(0, 2))
1257+
info_table.add_column("Key", style="cyan", justify="right")
1258+
info_table.add_column("Value", style="white")
1259+
1260+
info_table.add_row("CLI Version", cli_version)
1261+
info_table.add_row("Template Version", template_version)
1262+
info_table.add_row("Released", release_date)
1263+
info_table.add_row("", "")
1264+
info_table.add_row("Python", f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")
1265+
info_table.add_row("Platform", platform.system())
1266+
info_table.add_row("Architecture", platform.machine())
1267+
info_table.add_row("OS Version", platform.version())
1268+
1269+
panel = Panel(
1270+
info_table,
1271+
title="[bold cyan]Specify CLI Information[/bold cyan]",
1272+
border_style="cyan",
1273+
padding=(1, 2)
1274+
)
1275+
1276+
console.print(panel)
1277+
console.print()
1278+
11991279
def main():
12001280
app()
12011281

0 commit comments

Comments
 (0)