mirror of
https://github.com/github/spec-kit.git
synced 2026-01-30 04:32:02 +00:00
Support for version command
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "specify-cli"
|
name = "specify-cli"
|
||||||
version = "0.0.20"
|
version = "0.0.21"
|
||||||
description = "Specify CLI, part of GitHub Spec Kit. A tool to bootstrap your projects for Spec-Driven Development (SDD)."
|
description = "Specify CLI, part of GitHub Spec Kit. A tool to bootstrap your projects for Spec-Driven Development (SDD)."
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|||||||
@@ -1196,6 +1196,86 @@ def check():
|
|||||||
if not any(agent_results.values()):
|
if not any(agent_results.values()):
|
||||||
console.print("[dim]Tip: Install an AI assistant for the best experience[/dim]")
|
console.print("[dim]Tip: Install an AI assistant for the best experience[/dim]")
|
||||||
|
|
||||||
|
@app.command()
|
||||||
|
def version():
|
||||||
|
"""Display version and system information."""
|
||||||
|
import platform
|
||||||
|
import importlib.metadata
|
||||||
|
|
||||||
|
show_banner()
|
||||||
|
|
||||||
|
# Get CLI version from package metadata
|
||||||
|
cli_version = "unknown"
|
||||||
|
try:
|
||||||
|
cli_version = importlib.metadata.version("specify-cli")
|
||||||
|
except Exception:
|
||||||
|
# Fallback: try reading from pyproject.toml if running from source
|
||||||
|
try:
|
||||||
|
import tomllib
|
||||||
|
pyproject_path = Path(__file__).parent.parent.parent / "pyproject.toml"
|
||||||
|
if pyproject_path.exists():
|
||||||
|
with open(pyproject_path, "rb") as f:
|
||||||
|
data = tomllib.load(f)
|
||||||
|
cli_version = data.get("project", {}).get("version", "unknown")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Fetch latest template release version
|
||||||
|
repo_owner = "github"
|
||||||
|
repo_name = "spec-kit"
|
||||||
|
api_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/releases/latest"
|
||||||
|
|
||||||
|
template_version = "unknown"
|
||||||
|
release_date = "unknown"
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = client.get(
|
||||||
|
api_url,
|
||||||
|
timeout=10,
|
||||||
|
follow_redirects=True,
|
||||||
|
headers=_github_auth_headers(),
|
||||||
|
)
|
||||||
|
if response.status_code == 200:
|
||||||
|
release_data = response.json()
|
||||||
|
template_version = release_data.get("tag_name", "unknown")
|
||||||
|
# Remove 'v' prefix if present
|
||||||
|
if template_version != "unknown" and template_version.startswith("v"):
|
||||||
|
template_version = template_version[1:]
|
||||||
|
release_date = release_data.get("published_at", "unknown")
|
||||||
|
if release_date != "unknown":
|
||||||
|
# Format the date nicely
|
||||||
|
from datetime import datetime
|
||||||
|
try:
|
||||||
|
dt = datetime.fromisoformat(release_date.replace('Z', '+00:00'))
|
||||||
|
release_date = dt.strftime("%Y-%m-%d")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
info_table = Table(show_header=False, box=None, padding=(0, 2))
|
||||||
|
info_table.add_column("Key", style="cyan", justify="right")
|
||||||
|
info_table.add_column("Value", style="white")
|
||||||
|
|
||||||
|
info_table.add_row("CLI Version", cli_version)
|
||||||
|
info_table.add_row("Template Version", template_version)
|
||||||
|
info_table.add_row("Released", release_date)
|
||||||
|
info_table.add_row("", "")
|
||||||
|
info_table.add_row("Python", f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")
|
||||||
|
info_table.add_row("Platform", platform.system())
|
||||||
|
info_table.add_row("Architecture", platform.machine())
|
||||||
|
info_table.add_row("OS Version", platform.version())
|
||||||
|
|
||||||
|
panel = Panel(
|
||||||
|
info_table,
|
||||||
|
title="[bold cyan]Specify CLI Information[/bold cyan]",
|
||||||
|
border_style="cyan",
|
||||||
|
padding=(1, 2)
|
||||||
|
)
|
||||||
|
|
||||||
|
console.print(panel)
|
||||||
|
console.print()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
app()
|
app()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user